summaryrefslogtreecommitdiff
path: root/tests/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2024-08-20 12:56:54 +0200
committerGitHub <noreply@github.com>2024-08-20 10:56:54 +0000
commit986d624b3a19df757b1ad05576cc0fb1d78dc2d4 (patch)
tree06b2e8e665e93d92fe03bbc9c992362155affb01 /tests/src
parenta30b681251ef684b4bcfdc43787ad058b5e600f6 (diff)
Share allocations for singletons (#4794)
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/world.rs9
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()),
+ }
}
}