diff options
| author | Abdul-Rahman Sibahi <asibahi@users.noreply.github.com> | 2024-10-31 14:52:11 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-31 11:52:11 +0000 |
| commit | b969c01b282287b44c3e131f8c0c53dcbb304e30 (patch) | |
| tree | fe58484bfa76e7fe7a35bf0bffdc339b24621693 /crates/typst-realize | |
| parent | 644ed252dda1a0785d2bee577a89322416f4d950 (diff) | |
Replace `once_cell`'s `Lazy` as much as possible (#4617)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-realize')
| -rw-r--r-- | crates/typst-realize/Cargo.toml | 1 | ||||
| -rw-r--r-- | crates/typst-realize/src/lib.rs | 6 |
2 files changed, 3 insertions, 4 deletions
diff --git a/crates/typst-realize/Cargo.toml b/crates/typst-realize/Cargo.toml index 78bda259..cbf0cbca 100644 --- a/crates/typst-realize/Cargo.toml +++ b/crates/typst-realize/Cargo.toml @@ -22,7 +22,6 @@ arrayvec = { workspace = true } bumpalo = { workspace = true } comemo = { workspace = true } ecow = { workspace = true } -once_cell = { workspace = true } regex = { workspace = true } [lints] diff --git a/crates/typst-realize/src/lib.rs b/crates/typst-realize/src/lib.rs index 58668962..ec7ee0ae 100644 --- a/crates/typst-realize/src/lib.rs +++ b/crates/typst-realize/src/lib.rs @@ -5,12 +5,12 @@ //! further. use std::borrow::Cow; +use std::cell::LazyCell; use arrayvec::ArrayVec; use bumpalo::collections::{String as BumpString, Vec as BumpVec}; use comemo::Track; use ecow::EcoString; -use once_cell::unsync::Lazy; use typst_library::diag::{bail, At, SourceResult}; use typst_library::engine::Engine; use typst_library::foundations::{ @@ -420,7 +420,7 @@ fn verdict<'a>( // it to determine whether a particular show rule was already applied to the // `target` previously. For this purpose, show rules are indexed from the // top of the chain as the chain might grow to the bottom. - let depth = Lazy::new(|| styles.recipes().count()); + let depth = LazyCell::new(|| styles.recipes().count()); for (r, recipe) in styles.recipes().enumerate() { // We're not interested in recipes that don't match. @@ -1032,7 +1032,7 @@ fn find_regex_match_in_str<'a>( let mut revoked = SmallBitSet::new(); let mut leftmost: Option<(regex::Match, RecipeIndex, &Recipe)> = None; - let depth = Lazy::new(|| styles.recipes().count()); + let depth = LazyCell::new(|| styles.recipes().count()); for entry in styles.entries() { let recipe = match &**entry { |
