summaryrefslogtreecommitdiff
path: root/crates/typst-utils
diff options
context:
space:
mode:
authorAbdul-Rahman Sibahi <asibahi@users.noreply.github.com>2024-10-31 14:52:11 +0300
committerGitHub <noreply@github.com>2024-10-31 11:52:11 +0000
commitb969c01b282287b44c3e131f8c0c53dcbb304e30 (patch)
treefe58484bfa76e7fe7a35bf0bffdc339b24621693 /crates/typst-utils
parent644ed252dda1a0785d2bee577a89322416f4d950 (diff)
Replace `once_cell`'s `Lazy` as much as possible (#4617)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-utils')
-rw-r--r--crates/typst-utils/src/macros.rs3
-rw-r--r--crates/typst-utils/src/pico.rs9
2 files changed, 5 insertions, 7 deletions
diff --git a/crates/typst-utils/src/macros.rs b/crates/typst-utils/src/macros.rs
index dd60a2e0..e286d05f 100644
--- a/crates/typst-utils/src/macros.rs
+++ b/crates/typst-utils/src/macros.rs
@@ -2,8 +2,7 @@
#[macro_export]
macro_rules! singleton {
($ty:ty, $value:expr) => {{
- static VALUE: $crate::once_cell::sync::Lazy<$ty> =
- $crate::once_cell::sync::Lazy::new(|| $value);
+ static VALUE: ::std::sync::LazyLock<$ty> = ::std::sync::LazyLock::new(|| $value);
&*VALUE
}};
}
diff --git a/crates/typst-utils/src/pico.rs b/crates/typst-utils/src/pico.rs
index d531f14a..dcab39b6 100644
--- a/crates/typst-utils/src/pico.rs
+++ b/crates/typst-utils/src/pico.rs
@@ -1,13 +1,12 @@
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
-use std::sync::RwLock;
-
-use once_cell::sync::Lazy;
+use std::sync::{LazyLock, RwLock};
/// The global string interner.
-static INTERNER: Lazy<RwLock<Interner>> =
- Lazy::new(|| RwLock::new(Interner { to_id: HashMap::new(), from_id: Vec::new() }));
+static INTERNER: LazyLock<RwLock<Interner>> = LazyLock::new(|| {
+ RwLock::new(Interner { to_id: HashMap::new(), from_id: Vec::new() })
+});
/// A string interner.
struct Interner {