Skip to main content

StaticGlobal

Struct StaticGlobal 

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

Static reference to arbitrary managed data. Guaranteed to be initialized at most once.

Implementations§

Source§

impl<T> StaticGlobal<T>
where T: Managed<'static, 'static> + Typecheck,

Source

pub const fn new(path: &'static str) -> StaticGlobal<T>

Define a new static global available at path.

The global is looked up only once when this data is accessedd for the first time. The path argument must be the full path to the data, e.g. "Main.Submodule.Foo".

Source

pub fn get_or_init<'target, Tgt>(&self, target: &Tgt) -> T
where Tgt: Target<'target>,

Get the global data, look it up if it doesn’t exist yet.

The global must exist and be an instance of T. Otherwise this method will panic.

Source§

impl StaticGlobal<ValueUnbound>

Source

pub const fn new_value(path: &'static str) -> StaticGlobal<ValueUnbound>

Define a new static global available at path.

The global is looked up only once when this data is accessedd for the first time. The path argument must be the full path to the data, e.g. "Main.Submodule.Foo".

Auto Trait Implementations§

§

impl<T> !Freeze for StaticGlobal<T>

§

impl<T> !RefUnwindSafe for StaticGlobal<T>

§

impl<T> !UnwindSafe for StaticGlobal<T>

§

impl<T> Send for StaticGlobal<T>

§

impl<T> Sync for StaticGlobal<T>

§

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

§

impl<T> UnsafeUnpin for StaticGlobal<T>

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> AttachParachute for T
where T: 'static + Send + Sync,

Source§

fn attach_parachute<'scope, Tgt: Target<'scope>>( self, target: Tgt, ) -> WithParachute<'scope, Self>

Attach a parachute to this data. 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>,

Source§

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>,

Source§

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.