Struct static_init::lazy::LesserLazyFinalize

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

The actual type of statics attributed with #[dynamic(finalize)]. 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> LesserLazyFinalize<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> LesserLazyFinalize<T, G>
where G: 'static + Generator<T> + Sync, T: Sync + Finaly,

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 LesserLazyFinalize<T, G>
where G: 'static + Generator<T> + Sync, T: 'static + Sync + Finaly,

§

type Target = T

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<T, G> LazyAccess for &'static LesserLazyFinalize<T, G>
where G: 'static + Generator<T> + Sync, T: Sync + Finaly,

§

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 LesserLazyFinalize<T, G>
where G: 'static + Generator<T> + Sync, T: Sync + Finaly,

source§

fn phase(this: &Self) -> Phase

return the current phase

Auto Trait Implementations§

§

impl<T, G = fn() -> T> !Freeze for LesserLazyFinalize<T, G>

§

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

§

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

§

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

§

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

§

impl<T, G = fn() -> T> !UnwindSafe for LesserLazyFinalize<T, G>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where 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 T
where 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.