Skip to content

Commit d555c1e

Browse files
Removed crate once_cell (#4083)
* Removed crate once_cell As of rust_version 1.80.0 there are now equivalent options in std. Async and sync changes are as follows. -use once_cell::sync::Lazy; +use std::sync::LazyLock; -use once_cell::sync::Lazy; +use std::sync::LazyLock; * ran cargo fmt. * fixed server_fn errors. * cargo fmt fixes. * "use srd::sync" becomes "use std::sync". * fixed formatting issue. * formatting issues. * Fixed error in examples/server_fns_axum * more formatting issues. * more formatting issues. * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent 40ea200 commit d555c1e

File tree

21 files changed

+166
-185
lines changed

21 files changed

+166
-185
lines changed

Cargo.lock

Lines changed: 120 additions & 129 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ exclude = ["benchmarks", "examples", "projects"]
4242
[workspace.package]
4343
version = "0.8.2"
4444
edition = "2021"
45-
rust-version = "1.76"
45+
rust-version = "1.80"
4646

4747
[workspace.dependencies]
4848
# members
@@ -85,7 +85,6 @@ rstml = { default-features = false, version = "0.12.1" }
8585
rustc_version = { default-features = false, version = "0.4.1" }
8686
guardian = { default-features = false, version = "1.3.0" }
8787
rustc-hash = { default-features = false, version = "2.1.1" }
88-
once_cell = { default-features = false, version = "1.21.3" }
8988
actix-web = { default-features = false, version = "4.11.0" }
9089
tracing = { default-features = false, version = "0.1.41" }
9190
slotmap = { default-features = false, version = "1.0.7" }

examples/counter_isomorphic/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ leptos = { path = "../../leptos" }
2323
leptos_actix = { path = "../../integrations/actix", optional = true }
2424
leptos_router = { path = "../../router" }
2525
log = "0.4.22"
26-
once_cell = "1.19"
2726
gloo-net = { version = "0.6.0" }
2827
wasm-bindgen = "0.2.93"
2928
serde = { version = "1.0", features = ["derive"] }

examples/server_fns_axum/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ strum = { version = "0.27.1", features = ["strum_macros", "derive"] }
3838
notify = { version = "8.0", optional = true }
3939
pin-project-lite = "0.2.14"
4040
dashmap = { version = "6.0", optional = true }
41-
once_cell = { version = "1.19", optional = true }
4241
async-broadcast = { version = "0.7.1", optional = true }
4342
bytecheck = "0.8.0"
4443
rkyv = { version = "0.8.8" }
@@ -54,7 +53,6 @@ ssr = [
5453
"dep:leptos_axum",
5554
"dep:notify",
5655
"dep:dashmap",
57-
"dep:once_cell",
5856
"dep:async-broadcast",
5957
]
6058

examples/server_fns_axum/src/app.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,16 @@ pub fn FileUploadWithProgress() -> impl IntoView {
424424
use async_broadcast::{broadcast, Receiver, Sender};
425425
use dashmap::DashMap;
426426
use futures::Stream;
427-
use once_cell::sync::Lazy;
427+
use std::sync::LazyLock;
428428

429429
struct File {
430430
total: usize,
431431
tx: Sender<usize>,
432432
rx: Receiver<usize>,
433433
}
434434

435-
static FILES: Lazy<DashMap<String, File>> = Lazy::new(DashMap::new);
435+
static FILES: LazyLock<DashMap<String, File>> =
436+
LazyLock::new(DashMap::new);
436437

437438
pub async fn add_chunk(filename: &str, len: usize) {
438439
println!("[{filename}]\tadding {len}");

hydration_context/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ futures = { workspace = true, default-features = true }
1616
serde = { features = ["derive"] , workspace = true, default-features = true }
1717
wasm-bindgen = { workspace = true, optional = true , default-features = true }
1818
js-sys = { optional = true , workspace = true, default-features = true }
19-
once_cell = { workspace = true, default-features = true }
2019
pin-project-lite = { workspace = true, default-features = true }
2120

2221
[features]

hydration_context/src/hydrate.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ use super::{SerializedDataId, SharedContext};
77
use crate::{PinnedFuture, PinnedStream};
88
use core::fmt::Debug;
99
use js_sys::Array;
10-
use once_cell::sync::Lazy;
1110
use std::{
1211
fmt::Display,
13-
sync::atomic::{AtomicBool, AtomicUsize, Ordering},
12+
sync::{
13+
atomic::{AtomicBool, AtomicUsize, Ordering},
14+
LazyLock,
15+
},
1416
};
1517
use throw_error::{Error, ErrorId};
1618
use wasm_bindgen::{prelude::wasm_bindgen, JsCast};
@@ -79,8 +81,8 @@ pub struct HydrateSharedContext {
7981
id: AtomicUsize,
8082
is_hydrating: AtomicBool,
8183
during_hydration: AtomicBool,
82-
errors: Lazy<Vec<(SerializedDataId, ErrorId, Error)>>,
83-
incomplete: Lazy<Vec<SerializedDataId>>,
84+
errors: LazyLock<Vec<(SerializedDataId, ErrorId, Error)>>,
85+
incomplete: LazyLock<Vec<SerializedDataId>>,
8486
}
8587

8688
impl HydrateSharedContext {
@@ -90,8 +92,8 @@ impl HydrateSharedContext {
9092
id: AtomicUsize::new(0),
9193
is_hydrating: AtomicBool::new(true),
9294
during_hydration: AtomicBool::new(true),
93-
errors: Lazy::new(serialized_errors),
94-
incomplete: Lazy::new(incomplete_chunks),
95+
errors: LazyLock::new(serialized_errors),
96+
incomplete: LazyLock::new(incomplete_chunks),
9597
}
9698
}
9799

@@ -104,8 +106,8 @@ impl HydrateSharedContext {
104106
id: AtomicUsize::new(0),
105107
is_hydrating: AtomicBool::new(false),
106108
during_hydration: AtomicBool::new(true),
107-
errors: Lazy::new(serialized_errors),
108-
incomplete: Lazy::new(incomplete_chunks),
109+
errors: LazyLock::new(serialized_errors),
110+
incomplete: LazyLock::new(incomplete_chunks),
109111
}
110112
}
111113
}

integrations/actix/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ tracing = { optional = true , workspace = true, default-features = true }
2828
tokio = { features = ["rt", "fs"] , workspace = true, default-features = true }
2929
send_wrapper = { workspace = true, default-features = true }
3030
dashmap = { workspace = true, default-features = true }
31-
once_cell = { workspace = true, default-features = true }
3231

3332
[package.metadata.docs.rs]
3433
rustdoc-args = ["--generate-link-to-definition"]

integrations/actix/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use leptos_router::{
3838
static_routes::{RegenerationFn, ResolvedStaticPath},
3939
ExpandOptionals, Method, PathSegment, RouteList, RouteListing, SsrMode,
4040
};
41-
use once_cell::sync::Lazy;
4241
use parking_lot::RwLock;
4342
use send_wrapper::SendWrapper;
4443
use server_fn::{
@@ -51,7 +50,7 @@ use std::{
5150
future::Future,
5251
ops::{Deref, DerefMut},
5352
path::Path,
54-
sync::Arc,
53+
sync::{Arc, LazyLock},
5554
};
5655

5756
/// This struct lets you define headers and override the status of the Response from an Element or a Server Function
@@ -1210,8 +1209,8 @@ impl StaticRouteGenerator {
12101209
}
12111210
}
12121211

1213-
static STATIC_HEADERS: Lazy<DashMap<String, ResponseOptions>> =
1214-
Lazy::new(DashMap::new);
1212+
static STATIC_HEADERS: LazyLock<DashMap<String, ResponseOptions>> =
1213+
LazyLock::new(DashMap::new);
12151214

12161215
fn was_404(owner: &Owner) -> bool {
12171216
let resp = owner.with(|| expect_context::<ResponseOptions>());

integrations/axum/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ leptos_meta = { workspace = true, features = ["ssr", "nonce"] }
2323
leptos_router = { workspace = true, features = ["ssr"] }
2424
leptos_integration_utils = { workspace = true }
2525
tachys = { workspace = true }
26-
once_cell = { workspace = true, default-features = true }
2726
parking_lot = { workspace = true, default-features = true }
2827
tokio = { default-features = false , workspace = true }
2928
tower = { features = ["util"] , workspace = true, default-features = true }

integrations/axum/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ use leptos_router::{
6969
static_routes::RegenerationFn, ExpandOptionals, PathSegment, RouteList,
7070
RouteListing, SsrMode,
7171
};
72-
#[cfg(feature = "default")]
73-
use once_cell::sync::Lazy;
7472
use parking_lot::RwLock;
7573
use server_fn::{error::ServerFnErrorErr, redirect::REDIRECT_HEADER};
7674
#[cfg(feature = "default")]
7775
use std::path::Path;
76+
#[cfg(feature = "default")]
77+
use std::sync::LazyLock;
7878
use std::{collections::HashSet, fmt::Debug, io, pin::Pin, sync::Arc};
7979
#[cfg(feature = "default")]
8080
use tower::util::ServiceExt;
@@ -1522,8 +1522,8 @@ impl StaticRouteGenerator {
15221522
}
15231523

15241524
#[cfg(feature = "default")]
1525-
static STATIC_HEADERS: Lazy<DashMap<String, ResponseOptions>> =
1526-
Lazy::new(DashMap::new);
1525+
static STATIC_HEADERS: LazyLock<DashMap<String, ResponseOptions>> =
1526+
LazyLock::new(DashMap::new);
15271527

15281528
#[cfg(feature = "default")]
15291529
fn was_404(owner: &Owner) -> bool {

meta/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ edition.workspace = true
1010

1111
[dependencies]
1212
leptos = { workspace = true }
13-
once_cell = { workspace = true, default-features = true }
1413
or_poisoned = { workspace = true }
1514
indexmap = { workspace = true, default-features = true }
1615
send_wrapper = { workspace = true, default-features = true }

meta/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ use leptos::{
6363
},
6464
IntoView,
6565
};
66-
use once_cell::sync::Lazy;
6766
use send_wrapper::SendWrapper;
6867
use std::{
6968
fmt::Debug,
7069
sync::{
7170
mpsc::{channel, Receiver, Sender},
72-
Arc,
71+
Arc, LazyLock,
7372
},
7473
};
7574
use wasm_bindgen::JsCast;
@@ -101,7 +100,7 @@ pub struct MetaContext {
101100
/// Metadata associated with the `<title>` element.
102101
pub(crate) title: TitleContext,
103102
/// The hydration cursor for the location in the `<head>` for arbitrary tags will be rendered.
104-
pub(crate) cursor: Arc<Lazy<SendWrapper<Cursor>>>,
103+
pub(crate) cursor: Arc<LazyLock<SendWrapper<Cursor>>>,
105104
}
106105

107106
impl MetaContext {
@@ -143,7 +142,7 @@ impl Default for MetaContext {
143142
))
144143
};
145144

146-
let cursor = Arc::new(Lazy::new(build_cursor));
145+
let cursor = Arc::new(LazyLock::new(build_cursor));
147146
Self {
148147
title: Default::default(),
149148
cursor,

projects/ory-kratos/e2e/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ fake = "2.9"
2121
tokio-tungstenite = "0.23.1"
2222
futures-util = "0.3.30"
2323
uuid = { version = "1.10", features = ["serde"] }
24-
once_cell = "1.19"
2524
futures = "0.3.30"
2625

2726
[[test]]
@@ -33,6 +32,5 @@ harness = false # Allow Cucumber to print output instead of libtest
3332
ssr = []
3433

3534
[dependencies]
36-
once_cell = "1.19.0"
3735
regex = "1.10.6"
3836
serde.workspace = true

projects/ory-kratos/e2e/tests/app_suite.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ use chromiumoxide::{
1818
use cucumber::World;
1919
use futures::channel::mpsc::Sender;
2020
use futures_util::stream::StreamExt;
21-
use once_cell::sync::Lazy;
21+
use std::sync::LazyLock;
2222
use serde::{Deserialize, Serialize};
2323
use std::{collections::HashMap, sync::Arc, time::Duration};
2424
use tokio::sync::RwLock;
2525
use tokio_tungstenite::connect_async;
2626
use uuid::Uuid;
27-
static EMAIL_ID_MAP: Lazy<RwLock<HashMap<String, String>>> =
28-
Lazy::new(|| RwLock::new(HashMap::new()));
27+
static EMAIL_ID_MAP: LazyLock<RwLock<HashMap<String, String>>> =
28+
LazyLock::new(|| RwLock::new(HashMap::new()));
2929

3030
#[derive(Clone, Debug, PartialEq)]
3131
pub struct RequestPair {
@@ -93,7 +93,7 @@ impl RequestPair {
9393
async fn main() -> Result<()> {
9494
// create a thread and store a
9595
// tokio-tungstenite client that connectsto http://127.0.0.1:1080/ws
96-
// and then stores the recieved messages in a once_cell::Lazy<RwLock<Vec<MailCrabMsg>>>
96+
// and then stores the recieved messages in a std::sync::LazyLock<RwLock<Vec<MailCrabMsg>>>
9797
// or a custom struct that matches the body or has specific impls for verify codes, links etc.
9898
let _ = tokio::spawn(async move {
9999
let (mut socket, _) = connect_async(
@@ -152,7 +152,7 @@ async fn main() -> Result<()> {
152152

153153
tokio::task::spawn(async move {
154154
while let Some(event) = log_events.next().await {
155-
if let Some(EventEntryAdded { entry }) =
155+
if let Some(EventEntryAdded { entry }) =
156156
Arc::<EventEntryAdded>::into_inner(event) {
157157
console_logs.write().await.push(format!(" {entry:#?} "));
158158
} else {
@@ -171,7 +171,7 @@ async fn main() -> Result<()> {
171171
} else {
172172
tracing::error!("tried to into inner but none")
173173
}
174-
174+
175175
}
176176
});
177177

@@ -208,7 +208,7 @@ async fn main() -> Result<()> {
208208
thing.cookies_before_request = cookies;
209209

210210
}
211-
211+
212212
}
213213
CookieEnum::AfterResp(req_id) => {
214214
let cookies = page
@@ -293,8 +293,8 @@ async fn main() -> Result<()> {
293293
} else {
294294
tracing::error!(" uhh err here")
295295
}
296-
297-
296+
297+
298298
}
299299
});
300300
// We don't need to join on our join handles, they will run detached and clean up whenever.

router/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ url = { workspace = true, default-features = true }
2222
js-sys = { workspace = true, default-features = true }
2323
wasm-bindgen = { workspace = true , default-features = true }
2424
tracing = { optional = true , workspace = true, default-features = true }
25-
once_cell = { workspace = true, default-features = true }
2625
send_wrapper = { workspace = true, default-features = true }
2726
thiserror = { workspace = true , default-features = true }
2827
percent-encoding = { optional = true , workspace = true, default-features = true }

server_fn/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ thiserror = { workspace = true, default-features = true }
2929
# registration system
3030
inventory = { optional = true, workspace = true, default-features = true }
3131
dashmap = { workspace = true, default-features = true }
32-
once_cell = { workspace = true, default-features = true }
3332

3433
## servers
3534
# actix

server_fn/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ use error::{FromServerFnError, ServerFnErrorErr};
151151
use futures::{pin_mut, SinkExt, Stream, StreamExt};
152152
use http::Method;
153153
use middleware::{BoxedService, Layer, Service};
154-
use once_cell::sync::Lazy;
155154
use redirect::call_redirect_hook;
156155
use request::Req;
157156
use response::{ClientRes, Res, TryRes};
@@ -169,7 +168,7 @@ use std::{
169168
marker::PhantomData,
170169
ops::{Deref, DerefMut},
171170
pin::Pin,
172-
sync::Arc,
171+
sync::{Arc, LazyLock},
173172
};
174173
#[doc(hidden)]
175174
pub use xxhash_rust;
@@ -862,7 +861,7 @@ pub use inventory;
862861
#[macro_export]
863862
macro_rules! initialize_server_fn_map {
864863
($req:ty, $res:ty) => {
865-
once_cell::sync::Lazy::new(|| {
864+
std::sync::LazyLock::new(|| {
866865
$crate::inventory::iter::<ServerFnTraitObj<$req, $res>>
867866
.into_iter()
868867
.map(|obj| {
@@ -981,7 +980,7 @@ impl<Req, Res> Clone for ServerFnTraitObj<Req, Res> {
981980

982981
#[allow(unused)] // used by server integrations
983982
type LazyServerFnMap<Req, Res> =
984-
Lazy<DashMap<(String, Method), ServerFnTraitObj<Req, Res>>>;
983+
LazyLock<DashMap<(String, Method), ServerFnTraitObj<Req, Res>>>;
985984

986985
#[cfg(feature = "ssr")]
987986
impl<Req: 'static, Res: 'static> inventory::Collect

server_fn/src/request/reqwest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use crate::{
55
};
66
use bytes::Bytes;
77
use futures::{Stream, StreamExt};
8-
use once_cell::sync::Lazy;
98
use reqwest::{
109
header::{ACCEPT, CONTENT_TYPE},
1110
Body,
1211
};
1312
pub use reqwest::{multipart::Form, Client, Method, Request, Url};
13+
use std::sync::LazyLock;
1414

15-
pub(crate) static CLIENT: Lazy<Client> = Lazy::new(Client::new);
15+
pub(crate) static CLIENT: LazyLock<Client> = LazyLock::new(Client::new);
1616

1717
impl<E> ClientReq<E> for Request
1818
where

tachys/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ reactive_stores = { workspace = true, optional = true }
2121
slotmap = { optional = true, workspace = true, default-features = true }
2222
oco_ref = { workspace = true, optional = true }
2323
async-trait = { workspace = true, default-features = true }
24-
once_cell = { workspace = true, default-features = true }
2524
paste = { workspace = true, default-features = true }
2625
erased = { workspace = true, default-features = true }
2726
wasm-bindgen = { workspace = true, default-features = true }

0 commit comments

Comments
 (0)