Struct static_init::UnSyncLazy[][src]

pub struct UnSyncLazy<T, G = fn() -> T> { /* fields omitted */ }

A version of Lazy whose reference can not be passed to other thread

Implementations

impl<T, G> UnSyncLazy<T, G>[src]

pub const fn from_generator(f: G) -> Self[src]

Build a new static object

Safety

This function may be unsafe if building any thing else than a thread local object or a static will be the cause of undefined behavior

pub const fn from_generator_with_info(f: G, info: StaticInfo) -> Self[src]

Build a new static object with debug information

Safety

This function may be unsafe if building any thing else than a thread local object or a static will be the cause of undefined behavior

impl<T, G> UnSyncLazy<T, G> where
    G: Generator<T>, 
[src]

pub fn get(this: &Self) -> &T[src]

Initialize if necessary then return a reference to the target.

Panics

Panic if previous attempt to initialize has panicked and the lazy policy does not tolorate further initialization attempt or if initialization panic.

pub fn try_get(this: &Self) -> Result<&T, AccessError>[src]

Return a reference to the target if initialized otherwise return an error.

pub fn get_mut(this: &mut Self) -> &mut T[src]

Initialize and return a mutable reference to the target

This method is extremly efficient as it does not requires any form of locking when initializing

pub fn try_get_mut(this: &mut Self) -> Result<&mut T, AccessError>[src]

Return a mutable reference to the target if initialized otherwise return an error.

This method is extremly efficient as it does not requires any form of locking when initializing

pub fn phase(this: &Self) -> Phase[src]

Return the phase

pub fn init(this: &Self) -> Phase[src]

Initialize the lazy if not yet initialized

Panic

Panic if the generator panics

impl<T, G> UnSyncLazy<T, Cell<Option<G>>> where
    G: FnOnce() -> T, 
[src]

pub fn new(g: G) -> Self[src]

Trait Implementations

impl<T: Debug, G> Debug for UnSyncLazy<T, G> where
    G: Generator<T>, 
[src]

impl<T: Default> Default for UnSyncLazy<T, fn() -> T>[src]

impl<T, G> Deref for UnSyncLazy<T, G> where
    G: Generator<T>, 
[src]

type Target = T

The resulting type after dereferencing.

impl<T, G> DerefMut for UnSyncLazy<T, G> where
    G: Generator<T>, 
[src]

impl<T, G> Drop for UnSyncLazy<T, G>[src]

impl<'a, T, G> LazyAccess for &'a UnSyncLazy<T, G> where
    G: Generator<T>, 
[src]

type Target = &'a T

impl<T, G> Phased for UnSyncLazy<T, G> where
    G: Generator<T>, 
[src]

Auto Trait Implementations

impl<T, G> RefUnwindSafe for UnSyncLazy<T, G> where
    G: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, G = fn() -> T> !Send for UnSyncLazy<T, G>

impl<T, G = fn() -> T> !Sync for UnSyncLazy<T, G>

impl<T, G> Unpin for UnSyncLazy<T, G> where
    G: Unpin,
    T: Unpin

impl<T, G> UnwindSafe for UnSyncLazy<T, G> where
    G: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.