lazy_static/
core_lazy.rs
1extern crate spin;
9
10use self::spin::Once;
11
12pub struct Lazy<T: Sync>(Once<T>);
13
14impl<T: Sync> Lazy<T> {
15 pub const INIT: Self = Lazy(Once::INIT);
16
17 #[inline(always)]
18 pub fn get<F>(&'static self, builder: F) -> &T
19 where
20 F: FnOnce() -> T,
21 {
22 self.0.call_once(builder)
23 }
24}
25
26#[macro_export]
27#[doc(hidden)]
28macro_rules! __lazy_static_create {
29 ($NAME:ident, $T:ty) => {
30 static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT;
31 };
32}