From 3241c7afcf40b041b7c5b982fe9fffa199779ddd Mon Sep 17 00:00:00 2001 From: Qkessler Date: Sat, 28 Dec 2024 16:24:02 +0100 Subject: [PATCH] Remove once_cell dependency preferring LazyLock `once_cell`'s features were stabilized and included in the standard library under the std::sync module. We can use `LazyLock` to have the same behaviour as `OnceCell::get_or_init`. --- argh/Cargo.toml | 1 - argh/src/lib.rs | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/argh/Cargo.toml b/argh/Cargo.toml index 0f3bf57..26ff6ff 100644 --- a/argh/Cargo.toml +++ b/argh/Cargo.toml @@ -16,7 +16,6 @@ argh_derive.workspace = true rust-fuzzy-search = "0.1.1" [dev-dependencies] -once_cell = "1.10.0" trybuild = "1.0.63" [features] diff --git a/argh/src/lib.rs b/argh/src/lib.rs index 998a4eb..728ee85 100644 --- a/argh/src/lib.rs +++ b/argh/src/lib.rs @@ -206,7 +206,7 @@ //! # use argh::DynamicSubCommand; //! # use argh::EarlyExit; //! # use argh::FromArgs; -//! # use once_cell::sync::OnceCell; +//! # use std::sync::LazyLock; //! //! #[derive(FromArgs, PartialEq, Debug)] //! /// Top-level command. @@ -240,8 +240,7 @@ //! //! impl DynamicSubCommand for Dynamic { //! fn commands() -> &'static [&'static CommandInfo] { -//! static RET: OnceCell> = OnceCell::new(); -//! RET.get_or_init(|| { +//! static RET: LazyLock> = LazyLock::new(|| { //! let mut commands = Vec::new(); //! //! // argh needs the `CommandInfo` structs we generate to be valid @@ -257,7 +256,8 @@ //! }))); //! //! commands -//! }) +//! }); +//! &RET //! } //! //! fn try_redact_arg_values(