doc.rust-lang.org
pub const fn into_inner(self) -> Option<T>
Consumes the cell, returning the wrapped value.
method
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get_or_init<F>(&self, f: F) -> &T
Gets the contents of the cell, initializing it to f() if the cell was uninitialized.
method
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get_mut(&mut self) -> Option<&mut T>
Gets the mutable reference to the underlying value.
method
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get(&self) -> Option<&T>
Gets the reference to the underlying value.
method
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct OnceCell<T>
A cell which can nominally be written to only once.
struct
core
Stable since 1.70.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new(f: F) -> LazyCell<T, F>
Creates a new lazy value with the given initializing function.
associated_function
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get_mut(this: &mut LazyCell<T, F>) -> Option<&mut T>
Returns a mutable reference to the value if initialized. Otherwise (if uninitialized or poisoned), returns None.
associated_function
core
Stable since 1.94.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn get(this: &LazyCell<T, F>) -> Option<&T>
Returns a reference to the value if initialized. Otherwise (if uninitialized or poisoned), returns None.
associated_function
core
Stable since 1.94.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn force_mut(this: &mut LazyCell<T, F>) -> &mut T
Forces the evaluation of this lazy value and returns a mutable reference to the result.
associated_function
core
Stable since 1.94.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn force(this: &LazyCell<T, F>) -> &T
Forces the evaluation of this lazy value and returns a reference to the result.
associated_function
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct LazyCell<T, F>
A value which is initialized on the first access.
struct
core
Stable since 1.80.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn raw_get(this: *const Self) -> *mut T
Gets a mutable pointer to the wrapped value. The difference from get is that this function accepts a raw pointer, which is useful to avoid the creation of temporary references.
associated_function
core
Stable since 1.56.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new(value: T) -> UnsafeCell<T>
Constructs a new instance of UnsafeCell which will wrap the specified value.
associated_function
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn into_inner(self) -> T
Unwraps the value, consuming the cell.
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying data.
method
core
Stable since 1.50.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn get(&self) -> *mut T
Gets a mutable pointer to the wrapped value.
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn from_mut(value: &mut T) -> &mut UnsafeCell<T>
Converts from &mut T to &mut UnsafeCell<T>.
associated_function
core
Stable since 1.84.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct UnsafeCell<T>
The core primitive for interior mutability in Rust.
struct
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn map_split<U, V, F>(orig: RefMut<'b, T>, f: F) -> (RefMut<'b, U>, RefMut<'b, V>)
Splits a RefMut into multiple RefMuts for different components of the borrowed data.
associated_function
core
Stable since 1.35.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn map<U, F>(orig: RefMut<'b, T>, f: F) -> RefMut<'b, U>
Makes a new RefMut for a component of the borrowed data, e.g., an enum variant.
associated_function
core
Stable since 1.8.0
Version 1.100.0-nightly