use once_cell::sync::OnceCell; /// Lazily initialized static variable. /// /// Used in generated code. /// /// Currently a wrapper around `once_cell`s `OnceCell`. pub struct Lazy { once_cell: OnceCell, } impl Lazy { /// Uninitialized state. pub const fn new() -> Lazy { Lazy { once_cell: OnceCell::new(), } } /// Lazily initialize the value. pub fn get(&self, f: impl FnOnce() -> T) -> &T { self.once_cell.get_or_init(f) } }