[−][src]Struct lazy_init::Lazy
Lazy<T>
is a lazily initialized synchronized holder type. You can think
of it as a LazyTransform
where the initial type doesn't exist.
Implementations
impl<T> Lazy<T>
[src]
pub fn new() -> Lazy<T>
[src]
Construct a new, uninitialized Lazy<T>
.
pub fn into_inner(self) -> Option<T>
[src]
Unwrap the contained value, returning Some
if the Lazy<T>
has been initialized
or None
if it has not.
impl<T> Lazy<T>
[src]
pub fn get_or_create<F>(&self, f: F) -> &T where
F: FnOnce() -> T,
[src]
F: FnOnce() -> T,
Get a reference to the contained value, invoking f
to create it
if the Lazy<T>
is uninitialized. It is guaranteed that if multiple
calls to get_or_create
race, only one will invoke its closure, and
every call will receive a reference to the newly created value.
The value stored in the Lazy<T>
is immutable after the closure returns
it, so think carefully about what you want to put inside!
pub fn get(&self) -> Option<&T>
[src]
Get a reference to the contained value, returning Some(ref)
if the
Lazy<T>
has been initialized or None
if it has not. It is
guaranteed that if a reference is returned it is to the value inside
the Lazy<T>
.
Trait Implementations
impl<T: Clone> Clone for Lazy<T>
[src]
impl<T> Debug for Lazy<T> where
T: Debug,
[src]
T: Debug,
impl<T> Default for Lazy<T>
[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Lazy<T>
[src]
impl<T> Send for Lazy<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Lazy<T> where
T: Send + Sync,
[src]
T: Send + Sync,
impl<T> Unpin for Lazy<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Lazy<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,