pub struct LesserLazy<T, G = fn() -> T> { /* private fields */ }
Expand description

The actual type of statics attributed with #[dynamic]. The method from_generator is unsafe because this kind of static can only safely be used through this attribute macros.

Implementations§

source§

impl<T, G> LesserLazy<T, G>

source

pub const unsafe fn from_generator(f: G) -> Self

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

source

pub const unsafe fn from_generator_with_info(f: G, info: StaticInfo) -> Self

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

source§

impl<T, G> LesserLazy<T, G>where G: 'static + Generator<T>,

source

pub fn try_get(this: &'static Self) -> Result<&'static T, AccessError>

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

source

pub fn get(this: &'static Self) -> &'static T

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.

source

pub fn phase(this: &'static Self) -> Phase

Return the phase

source

pub fn init(this: &'static Self) -> Phase

Initialize the lazy if not yet initialized

Panic

Panic if the generator panics

Trait Implementations§

source§

impl<T, G> Deref for LesserLazy<T, G>where G: 'static + Generator<T>, T: 'static,

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T, G> LazyAccess for &'static LesserLazy<T, G>where G: 'static + Generator<T>,

§

type Target = &'static T

source§

fn get(this: Self) -> &'static T

Initialize if necessary then return a reference to the target. Read more
source§

fn try_get(this: Self) -> Result<&'static T, AccessError>

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

fn phase(this: Self) -> Phase

The current phase of the static
source§

fn init(this: Self) -> Phase

Initialize the static if there were no previous attempt to initialize it.
source§

impl<T, G> Phased for LesserLazy<T, G>where G: 'static + Generator<T>,

source§

fn phase(this: &Self) -> Phase

return the current phase

Auto Trait Implementations§

§

impl<T, G = fn() -> T> !RefUnwindSafe for LesserLazy<T, G>

§

impl<T, G> Send for LesserLazy<T, G>where G: Send + Sync, T: Send,

§

impl<T, G> Sync for LesserLazy<T, G>where G: Sync, T: Sync,

§

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

§

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

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.