pub struct LazyCell<T, F = fn() -> T> { /* private fields */ }
Expand description
A value which is initialized on the first access.
Examples
#![feature(once_cell)]
use std::cell::LazyCell;
let lazy: LazyCell<i32> = LazyCell::new(|| {
println!("initializing");
92
});
println!("ready");
println!("{}", *lazy);
println!("{}", *lazy);
// Prints:
// ready
// initializing
// 92
// 92
RunImplementations
Trait Implementations
Auto Trait Implementations
impl<T, F = fn() -> T> !RefUnwindSafe for LazyCell<T, F>
impl<T, F> Send for LazyCell<T, F> where
F: Send,
T: Send,
impl<T, F = fn() -> T> !Sync for LazyCell<T, F>
impl<T, F> Unpin for LazyCell<T, F> where
F: Unpin,
T: Unpin,
impl<T, F> UnwindSafe for LazyCell<T, F> where
F: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more