pub struct StaticKey<T: 'static> { /* private fields */ }
Expand description
An object that is rarely modified but frequently matched on.
This type can only be constructed using static_key!
macro.
Implementations§
Source§impl<T> StaticKey<T>
impl<T> StaticKey<T>
Sourcepub fn with<R>(&self, callback: impl FnOnce(&T) -> R) -> R
pub fn with<R>(&self, callback: impl FnOnce(&T) -> R) -> R
Acquire a reference to the value of this key.
§Performance
StaticKey
s are not intended to be used like cell/locks, so this is not an especially
optimised accessor. This method should be rarely used.
Sourcepub fn get(&self) -> Twhere
T: Copy,
pub fn get(&self) -> Twhere
T: Copy,
Returns a copy of the value of this key.
§Performance
StaticKey
s are not intended to be used like cell/locks, so this is not an especially
optimised accessor. This method should be rarely used.
Trait Implementations§
impl<T: Send> Send for StaticKey<T>
impl<T: Send> Sync for StaticKey<T>
Auto Trait Implementations§
impl<T> !Freeze for StaticKey<T>
impl<T> !RefUnwindSafe for StaticKey<T>
impl<T> Unpin for StaticKey<T>where
T: Unpin,
impl<T> !UnwindSafe for StaticKey<T>
Blanket Implementations§
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