Skip to content

Commit

Permalink
Use stdlib LazyLock instead of once_cell.
Browse files Browse the repository at this point in the history
  • Loading branch information
orium committed Aug 9, 2024
1 parent ed2a1df commit 0bcd8ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.2.1-pre"
authors = ["Diogo Sousa <[email protected]>"]

edition = "2021"
rust-version = "1.59.0"
rust-version = "1.80.0"

homepage = "https://github.com/orium/dirty-debug"
repository = "https://github.com/orium/dirty-debug"
Expand Down Expand Up @@ -39,17 +39,16 @@ codecov = { repository = "orium/dirty-debug", branch = "main", service = "github
fatal-warnings = []

[dependencies]
once_cell = "1.15.0"
dashmap = "5.4.0"
dashmap = "5.5.0"

[dev-dependencies]
rand = "0.8.1"
rand = "0.8.5"
indoc = "2.0.3"

[lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
correctness = "deny"
all = { level = "warn", priority = -2 }
pedantic = { level = "warn", priority = -2 }
correctness = { level = "deny", priority = -1 }

inline-always = "allow"
match-bool = "allow"
Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@
//! ```
use dashmap::DashMap;
use once_cell::sync::Lazy;
use std::fmt;
use std::fs::File;
use std::io;
use std::io::Write;
use std::net::TcpStream;
use std::str::FromStr;
use std::sync::LazyLock;

static DIRTY_FILES: Lazy<DashMap<&str, File>> = Lazy::new(DashMap::new);
static DIRTY_FILES: LazyLock<DashMap<&str, File>> = LazyLock::new(DashMap::new);

static DIRTY_TCP: Lazy<DashMap<(&str, u16), TcpStream>> = Lazy::new(DashMap::new);
static DIRTY_TCP: LazyLock<DashMap<(&str, u16), TcpStream>> = LazyLock::new(DashMap::new);

/// Writes a message to the given location. The message will be formatted.
///
Expand Down Expand Up @@ -165,7 +165,6 @@ mod test {
use std::io::Read;
use std::net::TcpStream;
use std::thread::JoinHandle;
use std::usize;

struct TempFilepath {
filepath: String,
Expand Down Expand Up @@ -242,7 +241,7 @@ mod test {
/// needs to be a string with a static lifetime to allow it to be stored without cloning it.
macro_rules! make_static {
($str:expr) => {{
static CELL: ::once_cell::sync::OnceCell<String> = ::once_cell::sync::OnceCell::new();
static CELL: ::std::sync::OnceLock<String> = ::std::sync::OnceLock::new();
CELL.set($str.to_owned()).unwrap();
CELL.get().unwrap().as_str()
}};
Expand Down

0 comments on commit 0bcd8ba

Please sign in to comment.