Struct tagged_cell::TaggedCell
source · [−]pub struct TaggedCell<T, Tag> { /* private fields */ }
Expand description
Top level structure to support initializable and thread safe static variables. Use tagged_cell! macro to make this struct
Implementations
sourceimpl<T, Tag> TaggedCell<T, Tag>
impl<T, Tag> TaggedCell<T, Tag>
sourcepub fn init<F>(&self, f: F) -> Init<Tag> where
F: Fn() -> T,
pub fn init<F>(&self, f: F) -> Init<Tag> where
F: Fn() -> T,
Initialize a TaggedCell. This function initializes the cell, if not already initialized, using the provided function or closure. Additionally returns a zero-sized Tag, which is required to access the underlying data.
Each thread accessing a TaggedOnceCell should call this method to obtain a Tag, the initialization code will only run once. It is undetermined which thread will run the initialization code.
sourcepub fn get(&self, _: Init<Tag>) -> &T
pub fn get(&self, _: Init<Tag>) -> &T
Get the data within a TaggedCell, requires an tag (obtained via TaggedCell::init) to perform the access
Trait Implementations
impl<T: Send, Tag> Send for TaggedCell<T, Tag>
TaggedCell may be Sync. Guaranteed by ZST tag
impl<T: Sync + Send, Tag> Sync for TaggedCell<T, Tag>
TaggedCell may be Sync. Guaranteed by ZST tag
Auto Trait Implementations
impl<T, Tag> !RefUnwindSafe for TaggedCell<T, Tag>
impl<T, Tag> Unpin for TaggedCell<T, Tag> where
T: Unpin,
Tag: Unpin,
impl<T, Tag> UnwindSafe for TaggedCell<T, Tag> where
T: UnwindSafe,
Tag: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more