summaryrefslogtreecommitdiff
path: root/crates/typst-macros
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-macros
parent644ed252dda1a0785d2bee577a89322416f4d950 (diff)
Replace `once_cell`'s `Lazy` as much as possible (#4617)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-macros')
-rw-r--r--crates/typst-macros/src/elem.rs8
-rw-r--r--crates/typst-macros/src/func.rs6
-rw-r--r--crates/typst-macros/src/ty.rs4
3 files changed, 9 insertions, 9 deletions
diff --git a/crates/typst-macros/src/elem.rs b/crates/typst-macros/src/elem.rs
index 3b968f76..78a3c180 100644
--- a/crates/typst-macros/src/elem.rs
+++ b/crates/typst-macros/src/elem.rs
@@ -432,8 +432,8 @@ fn create_default_static(field: &Field) -> TokenStream {
};
quote! {
- static #const_ident: ::once_cell::sync::Lazy<#ty> =
- ::once_cell::sync::Lazy::new(#init);
+ static #const_ident: ::std::sync::LazyLock<#ty> =
+ ::std::sync::LazyLock::new(#init);
}
}
@@ -660,8 +660,8 @@ fn create_native_elem_impl(element: &Elem) -> TokenStream {
field_name: |id| id.try_into().ok().map(Fields::to_str),
field_from_styles: <#ident as #foundations::Fields>::field_from_styles,
local_name: #local_name,
- scope: #foundations::Lazy::new(|| #scope),
- params: #foundations::Lazy::new(|| ::std::vec![#(#params),*])
+ scope: ::std::sync::LazyLock::new(|| #scope),
+ params: ::std::sync::LazyLock::new(|| ::std::vec![#(#params),*])
}
};
diff --git a/crates/typst-macros/src/func.rs b/crates/typst-macros/src/func.rs
index d402efd9..b8ab7a36 100644
--- a/crates/typst-macros/src/func.rs
+++ b/crates/typst-macros/src/func.rs
@@ -321,9 +321,9 @@ fn create_func_data(func: &Func) -> TokenStream {
docs: #docs,
keywords: &[#(#keywords),*],
contextual: #contextual,
- scope: #foundations::Lazy::new(|| #scope),
- params: #foundations::Lazy::new(|| ::std::vec![#(#params),*]),
- returns: #foundations::Lazy::new(|| <#returns as #foundations::Reflect>::output()),
+ scope: ::std::sync::LazyLock::new(|| #scope),
+ params: ::std::sync::LazyLock::new(|| ::std::vec![#(#params),*]),
+ returns: ::std::sync::LazyLock::new(|| <#returns as #foundations::Reflect>::output()),
}
}
}
diff --git a/crates/typst-macros/src/ty.rs b/crates/typst-macros/src/ty.rs
index 200798af..66284904 100644
--- a/crates/typst-macros/src/ty.rs
+++ b/crates/typst-macros/src/ty.rs
@@ -102,8 +102,8 @@ fn create(ty: &Type, item: Option<&syn::Item>) -> TokenStream {
title: #title,
docs: #docs,
keywords: &[#(#keywords),*],
- constructor: #foundations::Lazy::new(|| #constructor),
- scope: #foundations::Lazy::new(|| #scope),
+ constructor: ::std::sync::LazyLock::new(|| #constructor),
+ scope: ::std::sync::LazyLock::new(|| #scope),
}
};