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 /tests | |
| parent | a30b681251ef684b4bcfdc43787ad058b5e600f6 (diff) | |
Share allocations for singletons (#4794)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/src/world.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/src/world.rs b/tests/src/world.rs index 47b77d7e..799527fa 100644 --- a/tests/src/world.rs +++ b/tests/src/world.rs @@ -5,14 +5,13 @@ use std::io::Write; use std::path::{Path, PathBuf}; use std::sync::OnceLock; -use once_cell::sync::Lazy; use parking_lot::Mutex; use typst::diag::{bail, FileError, FileResult, StrResult}; use typst::foundations::{func, Bytes, Datetime, NoneValue, Repr, Smart, Value}; 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::visualize::Color; use typst::{Library, World}; @@ -29,8 +28,10 @@ impl TestWorld { /// This is cheap because the shared base for all test runs is lazily /// initialized just once. pub fn new(source: Source) -> Self { - static BASE: Lazy<TestBase> = Lazy::new(TestBase::default); - Self { main: source, base: &*BASE } + Self { + main: source, + base: singleton!(TestBase, TestBase::default()), + } } } |
