diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 12f64eb1..79448508 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -100,7 +100,7 @@ Imports are organized in groups, from least specific to more specific: use std::time; use git_ref_format as format; // Then, external dependencies. - use once_cell::sync::Lazy; + use serde_json::Value; use crate::crypto::PublicKey; // Finally, local crate imports. use crate::storage::refs::Refs; diff --git a/Cargo.lock b/Cargo.lock index 4fb88e7d..16de5ce1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2598,7 +2598,6 @@ dependencies = [ "log", "multibase", "nonempty 0.9.0", - "once_cell", "pretty_assertions", "qcheck", "qcheck-macros", @@ -2681,7 +2680,6 @@ dependencies = [ "git2", "log", "nonempty 0.9.0", - "once_cell", "qcheck", "qcheck-macros", "radicle-crypto", @@ -2790,7 +2788,6 @@ dependencies = [ "log", "netservices", "nonempty 0.9.0", - "once_cell", "qcheck", "qcheck-macros", "radicle", @@ -2825,7 +2822,6 @@ dependencies = [ name = "radicle-schemars" version = "0.1.0" dependencies = [ - "once_cell", "radicle", "schemars", "serde", @@ -2890,7 +2886,6 @@ dependencies = [ "git2", "inquire", "libc", - "once_cell", "pretty_assertions", "radicle-signals", "shlex", diff --git a/radicle-cob/Cargo.toml b/radicle-cob/Cargo.toml index 9569e010..0230392c 100644 --- a/radicle-cob/Cargo.toml +++ b/radicle-cob/Cargo.toml @@ -22,7 +22,6 @@ stable-commit-ids = [] fastrand = { version = "2.0.0" } log = { version = "0.4.17" } nonempty = { version = "0.9.0", features = ["serialize"] } -once_cell = { version = "1.13" } radicle-git-ext = { version = "0.8.0", features = ["serde"] } serde_json = { version = "1.0" } signature = { version = "2.2" } diff --git a/radicle-cob/src/backend/git/change.rs b/radicle-cob/src/backend/git/change.rs index c36a7a15..866e96ad 100644 --- a/radicle-cob/src/backend/git/change.rs +++ b/radicle-cob/src/backend/git/change.rs @@ -3,12 +3,12 @@ use std::collections::BTreeMap; use std::convert::TryFrom; use std::path::PathBuf; +use std::sync::LazyLock; use git_ext::author::Author; use git_ext::commit::{headers::Headers, Commit}; use git_ext::Oid; use nonempty::NonEmpty; -use once_cell::sync::Lazy; use radicle_git_ext::commit::trailers::OwnedTrailer; use crate::change::store::Version; @@ -24,7 +24,7 @@ use crate::{ /// Name of the COB manifest file. pub const MANIFEST_BLOB_NAME: &str = "manifest"; /// Path under which COB embeds are kept. -pub static EMBEDS_PATH: Lazy = Lazy::new(|| PathBuf::from("embeds")); +pub static EMBEDS_PATH: LazyLock = LazyLock::new(|| PathBuf::from("embeds")); pub mod error { use std::str::Utf8Error; diff --git a/radicle-node/Cargo.toml b/radicle-node/Cargo.toml index 35e757d5..20682cde 100644 --- a/radicle-node/Cargo.toml +++ b/radicle-node/Cargo.toml @@ -31,7 +31,6 @@ log = { version = "0.4.17", features = ["std"] } localtime = { version = "1.2.0" } netservices = { version = "0.8.0", features = ["io-reactor", "socket2"] } nonempty = { version = "0.9.0", features = ["serialize"] } -once_cell = { version = "1.13" } qcheck = { version = "1", default-features = false, optional = true } # N.b. this is required to use macros, even though it's re-exported # through radicle diff --git a/radicle-node/src/service/gossip.rs b/radicle-node/src/service/gossip.rs index 1ee912d8..2a677868 100644 --- a/radicle-node/src/service/gossip.rs +++ b/radicle-node/src/service/gossip.rs @@ -1,16 +1,16 @@ pub mod store; use std::str::FromStr; +use std::sync::LazyLock; use super::*; use crate::{PROTOCOL_VERSION, VERSION}; -use once_cell::sync::Lazy; use radicle::node::UserAgent; pub use store::{AnnouncementId, Error, RelayStatus, Store}; /// This node's user agent string. -pub static USER_AGENT: Lazy = Lazy::new(|| { +pub static USER_AGENT: LazyLock = LazyLock::new(|| { FromStr::from_str(format!("/radicle:{}/", VERSION.version).as_str()) .expect("user agent is valid") }); diff --git a/radicle-node/src/tests.rs b/radicle-node/src/tests.rs index 3d8ff039..1bd4290f 100644 --- a/radicle-node/src/tests.rs +++ b/radicle-node/src/tests.rs @@ -5,11 +5,11 @@ use std::default::*; use std::env; use std::io; use std::sync::Arc; +use std::sync::LazyLock; use std::time; use crossbeam_channel as chan; use netservices::Direction as Link; -use once_cell::sync::Lazy; use radicle::identity::Visibility; use radicle::node::address::Store as _; use radicle::node::device::Device; @@ -57,7 +57,7 @@ use crate::{git, identity, rad, runtime, service, test}; /// Default number of tests to run when testing things with high variance. pub const DEFAULT_TEST_CASES: usize = 10; /// Test cases to run when testing things with high variance. -pub static TEST_CASES: Lazy = Lazy::new(|| { +pub static TEST_CASES: LazyLock = LazyLock::new(|| { env::var("RAD_TEST_CASES") .ok() .and_then(|s| s.parse::().ok()) diff --git a/radicle-schemars/Cargo.toml b/radicle-schemars/Cargo.toml index 3fb30043..118b8bdb 100644 --- a/radicle-schemars/Cargo.toml +++ b/radicle-schemars/Cargo.toml @@ -13,7 +13,6 @@ name = "radicle-schemars" path = "src/main.rs" [dependencies] -once_cell = { version = "1.13" } schemars = { workspace = true } serde = { version = "1.0" } serde_json = { version = "1" } diff --git a/radicle-schemars/src/main.rs b/radicle-schemars/src/main.rs index 5a2dcb11..a8bbdefb 100644 --- a/radicle-schemars/src/main.rs +++ b/radicle-schemars/src/main.rs @@ -1,7 +1,7 @@ use std::io; use std::net; +use std::sync::LazyLock; -use once_cell::sync::Lazy; use schemars::{generate::*, *}; const SCHEMA_COMMAND: &str = "radicle::node::Command"; @@ -10,7 +10,7 @@ const SCHEMA_PROFILE_CONFIG: &str = "radicle::profile::Config"; const SCHEMAS: &[&str] = &[SCHEMA_COMMAND, SCHEMA_COMMAND_RESULT, SCHEMA_PROFILE_CONFIG]; -pub static ERROR_MSG: Lazy = Lazy::new(|| { +pub static ERROR_MSG: LazyLock = LazyLock::new(|| { let schemas = SCHEMAS.to_vec().join("\", \""); format!("Expected exactly one of the following schema names: [\"{schemas}\"].") }); diff --git a/radicle-term/Cargo.toml b/radicle-term/Cargo.toml index 8b670981..da9beb48 100644 --- a/radicle-term/Cargo.toml +++ b/radicle-term/Cargo.toml @@ -18,7 +18,6 @@ anstyle-query = { version = "1.0.0" } crossbeam-channel = { version = "0.5.6" } inquire = { version = "0.7.4", default-features = false, features = ["termion", "editor"] } libc = { version = "0.2" } -once_cell = { version = "1.13" } shlex = { version = "1.1" } termion = { version = "3" } thiserror = { version = "1" } diff --git a/radicle-term/src/ansi/paint.rs b/radicle-term/src/ansi/paint.rs index f7e3184d..0926abb3 100644 --- a/radicle-term/src/ansi/paint.rs +++ b/radicle-term/src/ansi/paint.rs @@ -1,10 +1,9 @@ use std::io::IsTerminal as _; use std::os::fd::{AsRawFd, BorrowedFd}; use std::sync::atomic::{AtomicBool, AtomicI32}; +use std::sync::LazyLock; use std::{fmt, sync}; -use once_cell::sync::Lazy; - use super::color::Color; use super::style::{Property, Style}; @@ -277,7 +276,7 @@ impl Paint<()> { /// Check 24-bit RGB color support. pub fn truecolor() -> bool { - static TRUECOLOR: Lazy = Lazy::new(anstyle_query::term_supports_color); + static TRUECOLOR: LazyLock = LazyLock::new(anstyle_query::term_supports_color); *TRUECOLOR } diff --git a/radicle-term/src/io.rs b/radicle-term/src/io.rs index 13d77f4a..b2251706 100644 --- a/radicle-term/src/io.rs +++ b/radicle-term/src/io.rs @@ -1,13 +1,13 @@ use std::ffi::OsStr; use std::fmt::Write; use std::process::Stdio; +use std::sync::LazyLock; use std::{env, fmt, io, process}; use inquire::ui::{ErrorMessageRenderConfig, StyleSheet, Styled}; use inquire::validator; use inquire::InquireError; use inquire::{ui::Color, ui::RenderConfig, Confirm, CustomType, Password}; -use once_cell::sync::Lazy; use zeroize::Zeroizing; use crate::command; @@ -26,7 +26,7 @@ pub const TAB: &str = " "; pub type Passphrase = Zeroizing; /// Render configuration. -pub static CONFIG: Lazy = Lazy::new(|| RenderConfig { +pub static CONFIG: LazyLock = LazyLock::new(|| RenderConfig { prompt: StyleSheet::new().with_fg(Color::LightCyan), prompt_prefix: Styled::new("?").with_fg(Color::LightBlue), answered_prompt_prefix: Styled::new("✓").with_fg(Color::LightGreen), diff --git a/radicle/Cargo.toml b/radicle/Cargo.toml index e5f3a6a0..f24876a5 100644 --- a/radicle/Cargo.toml +++ b/radicle/Cargo.toml @@ -26,7 +26,6 @@ localtime = { version = "1.2.0", features = ["serde"] } libc = { version = "0.2" } log = { version = "0.4.17", features = ["std"] } nonempty = { version = "0.9.0", features = ["serialize"] } -once_cell = { version = "1.13" } serde = { version = "1", features = ["derive"] } serde_json = { version = "1", features = ["preserve_order"] } siphasher = { version = "1.0.0" } diff --git a/radicle/src/cob/identity.rs b/radicle/src/cob/identity.rs index f3383c59..814fe919 100644 --- a/radicle/src/cob/identity.rs +++ b/radicle/src/cob/identity.rs @@ -1,8 +1,8 @@ use std::collections::BTreeMap; +use std::sync::LazyLock; use std::{fmt, ops::Deref, str::FromStr}; use crypto::{PublicKey, Signature}; -use once_cell::sync::Lazy; use radicle_cob::{Embed, ObjectId, TypeName}; use radicle_git_ext as git_ext; use radicle_git_ext::Oid; @@ -29,8 +29,8 @@ use crate::{ use super::{Author, EntryId}; /// Type name of an identity proposal. -pub static TYPENAME: Lazy = - Lazy::new(|| FromStr::from_str("xyz.radicle.id").expect("type name is valid")); +pub static TYPENAME: LazyLock = + LazyLock::new(|| FromStr::from_str("xyz.radicle.id").expect("type name is valid")); /// Identity operation. pub type Op = cob::Op; diff --git a/radicle/src/cob/issue.rs b/radicle/src/cob/issue.rs index b351dce1..3ad1d82e 100644 --- a/radicle/src/cob/issue.rs +++ b/radicle/src/cob/issue.rs @@ -3,8 +3,8 @@ pub mod cache; use std::collections::BTreeSet; use std::ops::Deref; use std::str::FromStr; +use std::sync::LazyLock; -use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -27,8 +27,8 @@ pub use cache::Cache; pub type Op = cob::Op; /// Type name of an issue. -pub static TYPENAME: Lazy = - Lazy::new(|| FromStr::from_str("xyz.radicle.issue").expect("type name is valid")); +pub static TYPENAME: LazyLock = + LazyLock::new(|| FromStr::from_str("xyz.radicle.issue").expect("type name is valid")); /// Identifier for an issue. pub type IssueId = ObjectId; diff --git a/radicle/src/cob/patch.rs b/radicle/src/cob/patch.rs index ee40f3ba..fc224a0c 100644 --- a/radicle/src/cob/patch.rs +++ b/radicle/src/cob/patch.rs @@ -5,10 +5,10 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::fmt; use std::ops::Deref; use std::str::FromStr; +use std::sync::LazyLock; use amplify::Wrapper; use nonempty::NonEmpty; -use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use storage::{HasRepoId, RepositoryError}; use thiserror::Error; @@ -32,8 +32,8 @@ use crate::storage; pub use cache::Cache; /// Type name of a patch. -pub static TYPENAME: Lazy = - Lazy::new(|| FromStr::from_str("xyz.radicle.patch").expect("type name is valid")); +pub static TYPENAME: LazyLock = + LazyLock::new(|| FromStr::from_str("xyz.radicle.patch").expect("type name is valid")); /// Patch operation. pub type Op = cob::Op; diff --git a/radicle/src/cob/thread.rs b/radicle/src/cob/thread.rs index 64deb0b6..f786bffb 100644 --- a/radicle/src/cob/thread.rs +++ b/radicle/src/cob/thread.rs @@ -1,8 +1,8 @@ use std::cmp::Ordering; use std::collections::{BTreeMap, BTreeSet}; use std::str::FromStr; +use std::sync::LazyLock; -use once_cell::sync::Lazy; use serde::{ser::SerializeStruct, Deserialize, Serialize}; use thiserror::Error; @@ -15,8 +15,8 @@ use crate::prelude::ReadRepository; /// Type name of a thread, as well as the domain for all thread operations. /// Note that threads are not usually used standalone. They are embeded into other COBs. -pub static TYPENAME: Lazy = - Lazy::new(|| FromStr::from_str("xyz.radicle.thread").expect("type name is valid")); +pub static TYPENAME: LazyLock = + LazyLock::new(|| FromStr::from_str("xyz.radicle.thread").expect("type name is valid")); /// Error applying an operation onto a state. #[derive(Error, Debug)] diff --git a/radicle/src/git.rs b/radicle/src/git.rs index 0d202e6f..7a67f4fa 100644 --- a/radicle/src/git.rs +++ b/radicle/src/git.rs @@ -4,9 +4,9 @@ use std::io; use std::path::Path; use std::process::Command; use std::str::FromStr; +use std::sync::LazyLock; use git_ext::ref_format as format; -use once_cell::sync::Lazy; use crate::collections::RandomMap; use crate::crypto::PublicKey; @@ -188,7 +188,7 @@ pub mod refs { /// /// `refs/rad/id` /// - pub static IDENTITY_BRANCH: Lazy = Lazy::new(|| { + pub static IDENTITY_BRANCH: LazyLock = LazyLock::new(|| { Qualified::from_components(name::component!("rad"), name::component!("id"), None) }); @@ -196,7 +196,7 @@ pub mod refs { /// /// `refs/rad/root` /// - pub static IDENTITY_ROOT: Lazy = Lazy::new(|| { + pub static IDENTITY_ROOT: LazyLock = LazyLock::new(|| { Qualified::from_components(name::component!("rad"), name::component!("root"), None) }); @@ -204,7 +204,7 @@ pub mod refs { /// /// `refs/rad/sigrefs` /// - pub static SIGREFS_BRANCH: Lazy = Lazy::new(|| { + pub static SIGREFS_BRANCH: LazyLock = LazyLock::new(|| { Qualified::from_components(name::component!("rad"), name::component!("sigrefs"), None) }); diff --git a/radicle/src/identity/doc.rs b/radicle/src/identity/doc.rs index bd34cc2e..a3b07274 100644 --- a/radicle/src/identity/doc.rs +++ b/radicle/src/identity/doc.rs @@ -6,9 +6,9 @@ use std::num::{NonZeroU32, NonZeroUsize}; use std::ops::{Deref, Not}; use std::path::Path; use std::str::FromStr; +use std::sync::LazyLock; use nonempty::NonEmpty; -use once_cell::sync::Lazy; use radicle_cob::type_name::{TypeName, TypeNameParse}; use radicle_git_ext::Oid; use serde::{de, Deserialize, Serialize}; @@ -28,7 +28,7 @@ pub use crypto::PublicKey; pub use id::*; /// Path to the identity document in the identity branch. -pub static PATH: Lazy<&Path> = Lazy::new(|| Path::new("radicle.json")); +pub static PATH: LazyLock<&Path> = LazyLock::new(|| Path::new("radicle.json")); /// Maximum length of a string in the identity document. pub const MAX_STRING_LENGTH: usize = 255; /// Maximum number of a delegates in the identity document. diff --git a/radicle/src/node/config.rs b/radicle/src/node/config.rs index 362e708c..0d13b508 100644 --- a/radicle/src/node/config.rs +++ b/radicle/src/node/config.rs @@ -23,10 +23,10 @@ pub mod seeds { use std::str::FromStr; use super::{ConnectAddress, PeerAddr}; - use once_cell::sync::Lazy; + use std::sync::LazyLock; /// A public Radicle seed node for the community. - pub static RADICLE_NODE_BOOTSTRAP_IRIS: Lazy = Lazy::new(|| { + pub static RADICLE_NODE_BOOTSTRAP_IRIS: LazyLock = LazyLock::new(|| { // SAFETY: `ConnectAddress` is known at compile time. #[allow(clippy::unwrap_used)] PeerAddr::from_str("z6MkrLMMsiPWUcNPHcRajuMi9mDfYckSoJyPwwnknocNYPm7@iris.radicle.xyz:8776") @@ -35,7 +35,7 @@ pub mod seeds { }); /// A public Radicle seed node for the community. - pub static RADICLE_NODE_BOOTSTRAP_ROSA: Lazy = Lazy::new(|| { + pub static RADICLE_NODE_BOOTSTRAP_ROSA: LazyLock = LazyLock::new(|| { // SAFETY: `ConnectAddress` is known at compile time. #[allow(clippy::unwrap_used)] PeerAddr::from_str("z6Mkmqogy2qEM2ummccUthFEaaHvyYmYBYh3dbe9W4ebScxo@rosa.radicle.xyz:8776") @@ -44,7 +44,7 @@ pub mod seeds { }); /// The Radicle seed node that the Radicle team uses. - pub static RADICLE_NODE_TEAM: Lazy = Lazy::new(|| { + pub static RADICLE_NODE_TEAM: LazyLock = LazyLock::new(|| { // SAFETY: `ConnectAddress` is known at compile time. #[allow(clippy::unwrap_used)] PeerAddr::from_str("z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz@seed.radicle.xyz:8776") diff --git a/radicle/src/rad.rs b/radicle/src/rad.rs index 5a0fcf5b..c90d84c1 100644 --- a/radicle/src/rad.rs +++ b/radicle/src/rad.rs @@ -2,8 +2,8 @@ use std::io; use std::path::{Path, PathBuf}; use std::str::FromStr; +use std::sync::LazyLock; -use once_cell::sync::Lazy; use thiserror::Error; use crate::cob::ObjectId; @@ -22,11 +22,13 @@ use crate::storage::{WriteRepository, WriteStorage}; use crate::{identity, storage}; /// Name of the radicle storage remote. -pub static REMOTE_NAME: Lazy = Lazy::new(|| git::refname!("rad")); +pub static REMOTE_NAME: LazyLock = LazyLock::new(|| git::refname!("rad")); /// Name of the radicle storage remote. -pub static REMOTE_COMPONENT: Lazy = Lazy::new(|| git::fmt::name::component!("rad")); +pub static REMOTE_COMPONENT: LazyLock = + LazyLock::new(|| git::fmt::name::component!("rad")); /// Refname used for pushing patches. -pub static PATCHES_REFNAME: Lazy = Lazy::new(|| git::refname!("refs/patches")); +pub static PATCHES_REFNAME: LazyLock = + LazyLock::new(|| git::refname!("refs/patches")); #[derive(Error, Debug)] pub enum InitError { diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index f67a0529..d6560792 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -5,10 +5,10 @@ pub mod transport; use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::ops::{Deref, DerefMut}; use std::path::{Path, PathBuf}; +use std::sync::LazyLock; use std::{fs, io}; use crypto::Verified; -use once_cell::sync::Lazy; use tempfile::TempDir; use crate::git::canonical::Canonical; @@ -33,11 +33,11 @@ pub use crate::storage::{Error, RepositoryError}; use super::refs::RefsAt; use super::{RemoteId, RemoteRepository, ValidateRepository}; -pub static NAMESPACES_GLOB: Lazy = - Lazy::new(|| git::refspec::pattern!("refs/namespaces/*")); -pub static SIGREFS_GLOB: Lazy = - Lazy::new(|| git::refspec::pattern!("refs/namespaces/*/rad/sigrefs")); -pub static CANONICAL_IDENTITY: Lazy = Lazy::new(|| { +pub static NAMESPACES_GLOB: LazyLock = + LazyLock::new(|| git::refspec::pattern!("refs/namespaces/*")); +pub static SIGREFS_GLOB: LazyLock = + LazyLock::new(|| git::refspec::pattern!("refs/namespaces/*/rad/sigrefs")); +pub static CANONICAL_IDENTITY: LazyLock = LazyLock::new(|| { git::Qualified::from_components( git::name::component!("rad"), git::name::component!("id"), diff --git a/radicle/src/storage/git/transport/remote/mock.rs b/radicle/src/storage/git/transport/remote/mock.rs index 851af3e1..c4585cde 100644 --- a/radicle/src/storage/git/transport/remote/mock.rs +++ b/radicle/src/storage/git/transport/remote/mock.rs @@ -2,19 +2,18 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; use std::str::FromStr; +use std::sync::LazyLock; use std::sync::{Mutex, Once}; use std::thread::ThreadId; use std::{process, thread}; -use once_cell::sync::Lazy; - use super::Url; use crate::storage::git::transport::ChildStream; use crate::storage::RemoteId; /// Nodes registered with the mock transport. -static NODES: Lazy>> = - Lazy::new(|| Mutex::new(HashMap::new())); +static NODES: LazyLock>> = + LazyLock::new(|| Mutex::new(HashMap::new())); /// The mock transport. #[derive(Default)]