InitStatic

Struct InitStatic 

Source
pub struct InitStatic<T> { /* private fields */ }
Expand description

A wrapper around OnceLock providing safe initialization and Deref support to mimic the ergonomics of lazy_static!.

Values must be initialized exactly once, either via InitStatic::init or by calling [init_static]. Accessing an uninitialized value will panic.

Implementations§

Source§

impl<T> InitStatic<T>

Source

pub const fn new(symbol: &'static Symbol) -> Self

Creates a new uninitialized InitStatic.

The value must be initialized using InitStatic::init or via the initialization registry before access.

Source

pub fn init(this: &Self, value: T)

Initializes the given static value.

This must be called exactly once. Subsequent calls will panic.

Source

pub const fn symbol(this: &Self) -> &'static Symbol

Trait Implementations§

Source§

impl<T: Debug> Debug for InitStatic<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Deref for InitStatic<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

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

Dereferences the value.
Source§

impl<T> DerefMut for InitStatic<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T: Display> Display for InitStatic<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for InitStatic<T>

§

impl<T> RefUnwindSafe for InitStatic<T>

§

impl<T> Send for InitStatic<T>
where T: Send,

§

impl<T> Sync for InitStatic<T>
where T: Sync + Send,

§

impl<T> Unpin for InitStatic<T>
where T: Unpin,

§

impl<T> UnwindSafe for InitStatic<T>
where T: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

impl<T> ToString for T
where T: Display + ?Sized,

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.