diff --git a/Cargo.lock b/Cargo.lock index 2e7cb78718..8f90141ee4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3713,7 +3713,6 @@ dependencies = [ "memoize", "notify", "object 0.36.7", - "once_cell", "open", "path-absolutize", "pdb", @@ -3890,9 +3889,6 @@ dependencies = [ [[package]] name = "dioxus-core-types" version = "0.7.0-alpha.0" -dependencies = [ - "once_cell", -] [[package]] name = "dioxus-desktop" @@ -3931,7 +3927,6 @@ dependencies = [ "ndk-sys 0.6.0+11769913", "objc", "objc_id", - "once_cell", "rand 0.8.5", "reqwest 0.12.15", "rfd", @@ -4072,7 +4067,6 @@ dependencies = [ "futures-util", "generational-box", "hyper-rustls 0.27.5", - "once_cell", "parking_lot", "pin-project", "rustls 0.23.27", @@ -4280,7 +4274,6 @@ dependencies = [ "dioxus-lib", "jni", "libc", - "once_cell", ] [[package]] @@ -4489,7 +4482,6 @@ dependencies = [ "hyper-rustls 0.27.5", "hyper-util", "inventory", - "once_cell", "parking_lot", "pin-project", "rustls 0.23.27", @@ -4517,7 +4509,6 @@ dependencies = [ "futures-channel", "futures-util", "generational-box", - "once_cell", "parking_lot", "rand 0.8.5", "reqwest 0.12.15", @@ -5573,7 +5564,6 @@ dependencies = [ "dioxus", "futures", "futures-util", - "once_cell", "serde", "tokio", ] @@ -15913,7 +15903,6 @@ dependencies = [ "futures", "getrandom 0.2.16", "js-sys", - "once_cell", "reqwest 0.12.15", "wasm-bindgen", "wasm-bindgen-futures", diff --git a/Cargo.toml b/Cargo.toml index f1af72c3cc..721d499224 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -257,7 +257,6 @@ reqwest = "0.12.12" owo-colors = "4.2.0" ciborium = "0.2.2" base64 = "0.22.1" -once_cell = "1.20.3" uuid = "1.15.1" convert_case = "0.8.0" tungstenite = { version = "0.26.2" } diff --git a/examples/fullstack-streaming/Cargo.toml b/examples/fullstack-streaming/Cargo.toml index 1df8508651..cda0ea11e4 100644 --- a/examples/fullstack-streaming/Cargo.toml +++ b/examples/fullstack-streaming/Cargo.toml @@ -12,7 +12,6 @@ serde = { workspace = true } futures = { workspace = true } tokio = { workspace = true, optional = true } futures-util.workspace = true -once_cell = { workspace = true } [features] default = [] diff --git a/packages/cli/Cargo.toml b/packages/cli/Cargo.toml index f17a46bddf..f89e609a26 100644 --- a/packages/cli/Cargo.toml +++ b/packages/cli/Cargo.toml @@ -71,7 +71,6 @@ dunce = { workspace = true } dirs = { workspace = true } reqwest = { workspace = true, features = ["rustls-tls", "trust-dns", "json"] } tower = { workspace = true } -once_cell = { workspace = true } # path lookup which = { version = "7.0.2" } diff --git a/packages/cli/src/build/request.rs b/packages/cli/src/build/request.rs index b92e9ffe70..cbc7475362 100644 --- a/packages/cli/src/build/request.rs +++ b/packages/cli/src/build/request.rs @@ -3322,10 +3322,10 @@ impl BuildRequest { /// /// It's not guaranteed that they're different from any other folder pub(crate) fn prepare_build_dir(&self) -> Result<()> { - use once_cell::sync::OnceCell; use std::fs::{create_dir_all, remove_dir_all}; + use std::sync::OnceLock; - static INITIALIZED: OnceCell> = OnceCell::new(); + static INITIALIZED: OnceLock> = OnceLock::new(); let success = INITIALIZED.get_or_init(|| { if self.platform != Platform::Server { diff --git a/packages/cli/src/cli/create.rs b/packages/cli/src/cli/create.rs index 1b063efaec..fca942d952 100644 --- a/packages/cli/src/cli/create.rs +++ b/packages/cli/src/cli/create.rs @@ -242,14 +242,14 @@ fn remove_triple_newlines(string: &str) -> String { // #[cfg(test)] // pub(crate) mod tests { // use escargot::{CargoBuild, CargoRun}; -// use once_cell::sync::Lazy; +// use std::sync::LazyLock; // use std::fs::{create_dir_all, read_to_string}; // use std::path::{Path, PathBuf}; // use std::process::Command; // use tempfile::tempdir; // use toml::Value; -// static BINARY: Lazy = Lazy::new(|| { +// static BINARY: LazyLock = LazyLock::new(|| { // CargoBuild::new() // .bin(env!("CARGO_BIN_NAME")) // .current_release() diff --git a/packages/cli/src/cli/mod.rs b/packages/cli/src/cli/mod.rs index d6dac5c798..d2f6c97c1d 100644 --- a/packages/cli/src/cli/mod.rs +++ b/packages/cli/src/cli/mod.rs @@ -24,8 +24,8 @@ use crate::{error::Result, Error, StructuredOutput}; use clap::builder::styling::{AnsiColor, Effects, Style, Styles}; use clap::{Parser, Subcommand}; use html_parser::Dom; -use once_cell::sync::Lazy; use serde::Deserialize; +use std::sync::LazyLock; use std::{ fmt::Display, fs::File, @@ -123,7 +123,7 @@ impl Display for Commands { } } -pub(crate) static VERSION: Lazy = Lazy::new(|| { +pub(crate) static VERSION: LazyLock = LazyLock::new(|| { format!( "{} ({})", crate::dx_build_info::PKG_VERSION, diff --git a/packages/cli/src/cli/serve.rs b/packages/cli/src/cli/serve.rs index ebd1490b64..67b9e83536 100644 --- a/packages/cli/src/cli/serve.rs +++ b/packages/cli/src/cli/serve.rs @@ -1,7 +1,7 @@ use super::*; use crate::{AddressArguments, BuildArgs, TraceController}; use futures_util::FutureExt; -use once_cell::sync::OnceCell; +use std::sync::OnceLock; use std::{backtrace::Backtrace, panic::AssertUnwindSafe}; /// Serve the project @@ -102,7 +102,7 @@ impl ServeArgs { line: u32, column: u32, } - static BACKTRACE: OnceCell<(Backtrace, Option)> = OnceCell::new(); + static BACKTRACE: OnceLock<(Backtrace, Option)> = OnceLock::new(); // We *don't* want printing here, since it'll break the tui and log ordering. // diff --git a/packages/cli/src/logging.rs b/packages/cli/src/logging.rs index 7b7a6b0761..4b0e439832 100644 --- a/packages/cli/src/logging.rs +++ b/packages/cli/src/logging.rs @@ -18,7 +18,7 @@ use crate::{serve::ServeUpdate, Cli, Commands, Platform as TargetPlatform, Verbo use cargo_metadata::diagnostic::{Diagnostic, DiagnosticLevel}; use clap::Parser; use futures_channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender}; -use once_cell::sync::OnceCell; +use std::sync::OnceLock; use std::{ collections::HashMap, env, @@ -47,8 +47,8 @@ const LOG_FILE_NAME: &str = "dx.log"; const DX_SRC_FLAG: &str = "dx_src"; static TUI_ACTIVE: AtomicBool = AtomicBool::new(false); -static TUI_TX: OnceCell> = OnceCell::new(); -pub static VERBOSITY: OnceCell = OnceCell::new(); +static TUI_TX: OnceLock> = OnceLock::new(); +pub static VERBOSITY: OnceLock = OnceLock::new(); pub(crate) struct TraceController { pub(crate) tui_rx: UnboundedReceiver, diff --git a/packages/cli/src/settings.rs b/packages/cli/src/settings.rs index 456ff4f0e2..13b020ba36 100644 --- a/packages/cli/src/settings.rs +++ b/packages/cli/src/settings.rs @@ -1,6 +1,6 @@ use crate::{Result, TraceSrc}; -use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; +use std::sync::LazyLock; use std::{fs, path::PathBuf, sync::Arc}; use tracing::{error, trace, warn}; @@ -33,8 +33,8 @@ pub(crate) struct CliSettings { impl CliSettings { /// Load the settings from the local, global, or default config in that order pub(crate) fn load() -> Arc { - static SETTINGS: Lazy> = - Lazy::new(|| Arc::new(CliSettings::global_or_default())); + static SETTINGS: LazyLock> = + LazyLock::new(|| Arc::new(CliSettings::global_or_default())); SETTINGS.clone() } diff --git a/packages/core-types/Cargo.toml b/packages/core-types/Cargo.toml index d1b7cc60e1..a0d61ff568 100644 --- a/packages/core-types/Cargo.toml +++ b/packages/core-types/Cargo.toml @@ -11,4 +11,3 @@ keywords = ["dom", "ui", "gui", "react", ] [dependencies] -once_cell = { workspace = true } diff --git a/packages/core-types/src/bundled.rs b/packages/core-types/src/bundled.rs index 5fd1319eec..9ff7f9c07c 100644 --- a/packages/core-types/src/bundled.rs +++ b/packages/core-types/src/bundled.rs @@ -1,7 +1,7 @@ -use once_cell::sync::Lazy; +use std::sync::LazyLock; pub fn is_bundled_app() -> bool { - static BUNDLED: Lazy = Lazy::new(|| { + static BUNDLED: LazyLock = LazyLock::new(|| { // If the env var is set, we're bundled if std::env::var("DIOXUS_CLI_ENABLED").is_ok() { return true; diff --git a/packages/desktop/Cargo.toml b/packages/desktop/Cargo.toml index aab77c88f7..a3afd0ce11 100644 --- a/packages/desktop/Cargo.toml +++ b/packages/desktop/Cargo.toml @@ -47,7 +47,6 @@ futures-util = { workspace = true } urlencoding = { workspace = true } async-trait = { workspace = true } tao = { workspace = true, features = ["rwh_05"] } -once_cell = { workspace = true } dioxus-history = { workspace = true } base64 = { workspace = true } libc = "0.2.170" diff --git a/packages/desktop/src/android_sync_lock.rs b/packages/desktop/src/android_sync_lock.rs index 776f7ad257..b52ef2c39e 100644 --- a/packages/desktop/src/android_sync_lock.rs +++ b/packages/desktop/src/android_sync_lock.rs @@ -2,10 +2,9 @@ /// /// We want to acquire this mutex before doing anything with the virtualdom directly pub fn android_runtime_lock() -> std::sync::MutexGuard<'static, ()> { - use once_cell::sync::OnceCell; - use std::sync::Mutex; + use std::sync::{Mutex, OnceLock}; - static RUNTIME_LOCK: OnceCell> = OnceCell::new(); + static RUNTIME_LOCK: OnceLock> = OnceLock::new(); RUNTIME_LOCK.get_or_init(|| Mutex::new(())).lock().unwrap() } diff --git a/packages/fullstack/Cargo.toml b/packages/fullstack/Cargo.toml index e98c9c4009..a2d793a641 100644 --- a/packages/fullstack/Cargo.toml +++ b/packages/fullstack/Cargo.toml @@ -41,7 +41,6 @@ dioxus-mobile = { workspace = true, optional = true } tracing = { workspace = true } tracing-futures = { workspace = true, optional = true } -once_cell = { workspace = true } tokio-util = { workspace = true, features = ["rt"], optional = true } async-trait = { workspace = true, optional = true } diff --git a/packages/fullstack/src/lib.rs b/packages/fullstack/src/lib.rs index 2cd07f8eb1..05a2c6aa17 100644 --- a/packages/fullstack/src/lib.rs +++ b/packages/fullstack/src/lib.rs @@ -4,8 +4,6 @@ #![deny(missing_docs)] #![cfg_attr(docsrs, feature(doc_cfg))] -pub use once_cell; - #[cfg(all(feature = "web", feature = "document"))] mod web; diff --git a/packages/mobile/Cargo.toml b/packages/mobile/Cargo.toml index 4fa50df6f4..b89182fa29 100644 --- a/packages/mobile/Cargo.toml +++ b/packages/mobile/Cargo.toml @@ -15,7 +15,6 @@ dioxus-desktop = { workspace = true } dioxus-lib = { workspace = true } dioxus-cli-config = { workspace = true } libc = "0.2.170" -once_cell = { workspace = true } [target.'cfg(target_os = "android")'.dependencies] jni = "0.21.1" diff --git a/packages/playwright-tests/wasm-split-harness/Cargo.toml b/packages/playwright-tests/wasm-split-harness/Cargo.toml index 9b74c0a843..98dabef31f 100644 --- a/packages/playwright-tests/wasm-split-harness/Cargo.toml +++ b/packages/playwright-tests/wasm-split-harness/Cargo.toml @@ -15,6 +15,5 @@ js-sys = { workspace = true } wasm-bindgen = { workspace = true } wasm-bindgen-futures = { workspace = true } web-sys = { workspace = true, features = ["Document", "Window", "HtmlElement", "Text", "DomRectReadOnly", "console"] } -once_cell = { workspace = true } getrandom = { workspace = true, features = ["js"] } reqwest = { workspace = true, features = ["json"] } diff --git a/packages/server/Cargo.toml b/packages/server/Cargo.toml index 8560bbb5b8..487b765150 100644 --- a/packages/server/Cargo.toml +++ b/packages/server/Cargo.toml @@ -39,7 +39,6 @@ dioxus-interpreter-js = { workspace = true, optional = true } tracing = { workspace = true } tracing-futures = { workspace = true } -once_cell = { workspace = true } async-trait = { workspace = true } serde = { workspace = true } enumset = "1.1.5" @@ -108,4 +107,3 @@ aws-lc-rs = ["dep:aws-lc-rs"] [package.metadata.docs.rs] cargo-args = ["-Zunstable-options", "-Zrustdoc-scrape-examples"] features = ["axum", "web", "aws-lc-rs"] - diff --git a/packages/server/src/document.rs b/packages/server/src/document.rs index be688e2f98..757647e5d5 100644 --- a/packages/server/src/document.rs +++ b/packages/server/src/document.rs @@ -6,10 +6,10 @@ use std::cell::RefCell; use dioxus_lib::{document::*, prelude::*}; use dioxus_ssr::Renderer; -use once_cell::sync::Lazy; use parking_lot::RwLock; +use std::sync::LazyLock; -static RENDERER: Lazy> = Lazy::new(|| RwLock::new(Renderer::new())); +static RENDERER: LazyLock> = LazyLock::new(|| RwLock::new(Renderer::new())); /// Reset the static renderer to a fresh state, clearing its cache. pub(crate) fn reset_renderer() { diff --git a/packages/server/src/server.rs b/packages/server/src/server.rs index d400878a2d..3433298221 100644 --- a/packages/server/src/server.rs +++ b/packages/server/src/server.rs @@ -296,7 +296,7 @@ pub(crate) fn add_server_context( pub struct RenderHandleState { config: ServeConfig, build_virtual_dom: Arc VirtualDom + Send + Sync>, - ssr_state: once_cell::sync::OnceCell, + ssr_state: std::sync::OnceLock, } impl RenderHandleState { @@ -329,7 +329,7 @@ impl RenderHandleState { /// Set the [`SSRState`] for this [`RenderHandleState`]. Sharing a [`SSRState`] between multiple [`RenderHandleState`]s is more efficient than creating a new [`SSRState`] for each [`RenderHandleState`]. pub fn with_ssr_state(mut self, ssr_state: SSRState) -> Self { - self.ssr_state = once_cell::sync::OnceCell::new(); + self.ssr_state = std::sync::OnceLock::new(); if self.ssr_state.set(ssr_state).is_err() { panic!("SSRState already set"); } diff --git a/packages/signals/Cargo.toml b/packages/signals/Cargo.toml index bee9f97e1a..9faf2b2cfb 100644 --- a/packages/signals/Cargo.toml +++ b/packages/signals/Cargo.toml @@ -18,7 +18,6 @@ generational-box = { workspace = true } tracing = { workspace = true } serde = { workspace = true, features = ["derive"], optional = true } parking_lot = { workspace = true} -once_cell = { workspace = true} rustc-hash = { workspace = true } futures-channel = { workspace = true } futures-util = { workspace = true } diff --git a/packages/subsecond/subsecond/src/lib.rs b/packages/subsecond/subsecond/src/lib.rs index bc502198d5..1415eb1ff4 100644 --- a/packages/subsecond/subsecond/src/lib.rs +++ b/packages/subsecond/subsecond/src/lib.rs @@ -435,7 +435,11 @@ impl> HotFn { /// # Safety /// /// The [`HotFnPtr`] must be to a function whose arguments layouts haven't changed. - pub unsafe fn try_call_with_ptr(&mut self, ptr: HotFnPtr, args: A) -> Result { + pub unsafe fn try_call_with_ptr( + &mut self, + ptr: HotFnPtr, + args: A, + ) -> Result { if !cfg!(debug_assertions) { return Ok(self.inner.call_it(args)); }