pub struct LazyCell<T, F = fn() -> T> { /* private fields */ }
🔬This is a nightly-only experimental API. (
once_cell
#74465)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
sourceimpl<T, F> LazyCell<T, F>
impl<T, F> LazyCell<T, F>
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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