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>
impl<T> StaticGlobal<T>
Sourcepub const fn new(path: &'static str) -> StaticGlobal<T>
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".
Sourcepub fn get_or_init<'target, Tgt>(&self, target: &Tgt) -> Twhere
Tgt: Target<'target>,
pub fn get_or_init<'target, Tgt>(&self, target: &Tgt) -> Twhere
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>
impl StaticGlobal<ValueUnbound>
Sourcepub const fn new_value(path: &'static str) -> StaticGlobal<ValueUnbound>
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> AttachParachute for T
impl<T> AttachParachute for T
Source§fn attach_parachute<'scope, Tgt: Target<'scope>>(
self,
target: Tgt,
) -> WithParachute<'scope, Self>
fn attach_parachute<'scope, Tgt: Target<'scope>>( self, target: Tgt, ) -> WithParachute<'scope, Self>
Attach a parachute to this data. Read more
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more