From 6c5ee174569a1f9a6c0adc2d588cf918dcb8bcf3 Mon Sep 17 00:00:00 2001 From: Joakim Soderlund Date: Wed, 4 Sep 2024 19:19:03 +0200 Subject: [PATCH] Remove direct dependency on Lazy Static --- Cargo.lock | 45 ++++++++++++++++++++--------------------- Cargo.toml | 3 --- src/archive/interner.rs | 14 +++++++++++-- src/archive/story.rs | 8 +++----- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8f50c1..6f03c28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,10 +3,10 @@ version = 3 [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -64,9 +64,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.13" +version = "1.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b" dependencies = [ "shlex", ] @@ -197,7 +197,6 @@ version = "0.1.0" dependencies = [ "chrono", "hex", - "lazy_static", "rayon", "serde", "serde_json", @@ -228,9 +227,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", "miniz_oxide", @@ -288,9 +287,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.157" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "log" @@ -312,11 +311,11 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -367,9 +366,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -450,18 +449,18 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "serde" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -470,9 +469,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", "memchr", @@ -488,9 +487,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.75" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 874319f..27752a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,9 +24,6 @@ features = ["serde"] [dependencies.hex] version = "*" -[dependencies.lazy_static] -version = "*" - [dependencies.rayon] version = "*" diff --git a/src/archive/interner.rs b/src/archive/interner.rs index 76c24e3..b0eae29 100644 --- a/src/archive/interner.rs +++ b/src/archive/interner.rs @@ -3,6 +3,7 @@ use std::collections::HashSet; use std::hash::Hash; use std::sync::Arc; +use std::sync::LazyLock; use std::sync::RwLock; pub struct Interner(RwLock>>); @@ -11,8 +12,8 @@ impl Interner where T: Eq + Hash, { - pub fn new() -> Self { - Self(RwLock::new(HashSet::new())) + pub const fn r#static() -> LazyLock { + LazyLock::new(Self::default) } fn get(&self, value: &T) -> Option> { @@ -41,3 +42,12 @@ where self.get(&value).unwrap_or_else(|| self.set(value)) } } + +impl Default for Interner +where + T: Eq + Hash, +{ + fn default() -> Self { + Self(Default::default()) + } +} diff --git a/src/archive/story.rs b/src/archive/story.rs index 6a6ed83..1d76c63 100644 --- a/src/archive/story.rs +++ b/src/archive/story.rs @@ -1,9 +1,9 @@ //! Story meta. use std::sync::Arc; +use std::sync::LazyLock; use chrono::prelude::*; -use lazy_static::lazy_static; use serde::de::Error; use serde::Deserialize; use serde::Deserializer; @@ -11,10 +11,8 @@ use serde_json::Value; use super::interner::Interner; -lazy_static! { - pub(crate) static ref AUTHORS: Interner = Interner::new(); - pub(crate) static ref TAGS: Interner = Interner::new(); -} +pub(crate) static AUTHORS: LazyLock> = Interner::r#static(); +pub(crate) static TAGS: LazyLock> = Interner::r#static(); #[derive(Clone, Debug, Deserialize)] #[serde(deny_unknown_fields)]