diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-08-20 12:56:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-20 10:56:54 +0000 |
| commit | 986d624b3a19df757b1ad05576cc0fb1d78dc2d4 (patch) | |
| tree | 06b2e8e665e93d92fe03bbc9c992362155affb01 /crates/typst-ide/src | |
| parent | a30b681251ef684b4bcfdc43787ad058b5e600f6 (diff) | |
Share allocations for singletons (#4794)
Diffstat (limited to 'crates/typst-ide/src')
| -rw-r--r-- | crates/typst-ide/src/lib.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/typst-ide/src/lib.rs b/crates/typst-ide/src/lib.rs index 403a36ba..63ba6f75 100644 --- a/crates/typst-ide/src/lib.rs +++ b/crates/typst-ide/src/lib.rs @@ -97,13 +97,12 @@ fn summarize_font_family<'a>(variants: impl Iterator<Item = &'a FontInfo>) -> Ec #[cfg(test)] mod tests { - use once_cell::sync::Lazy; use typst::diag::{FileError, FileResult}; use typst::foundations::{Bytes, Datetime, Smart}; use typst::layout::{Abs, Margin, PageElem}; use typst::syntax::{FileId, Source}; use typst::text::{Font, FontBook, TextElem, TextSize}; - use typst::utils::LazyHash; + use typst::utils::{singleton, LazyHash}; use typst::{Library, World}; /// A world for IDE testing. @@ -118,15 +117,16 @@ mod tests { /// This is cheap because the shared base for all test runs is lazily /// initialized just once. pub fn new(text: &str) -> Self { - static BASE: Lazy<TestBase> = Lazy::new(TestBase::default); let main = Source::detached(text); - Self { main, base: &*BASE } + Self { + main, + base: singleton!(TestBase, TestBase::default()), + } } /// The ID of the main file in a `TestWorld`. pub fn main_id() -> FileId { - static ID: Lazy<FileId> = Lazy::new(|| Source::detached("").id()); - *ID + *singleton!(FileId, Source::detached("").id()) } } |
