pub struct Cell<T> { /* private fields */ }
Implementations
sourceimpl<T> Cell<T>
impl<T> Cell<T>
pub const fn new() -> Self
pub const fn new_with(init: T) -> Self
pub fn is_initialized(&self) -> bool
pub fn ref_num(&self) -> Result<usize, MemoryState>
sourcepub fn try_take(&self) -> Result<Option<T>, Error<()>>
pub fn try_take(&self) -> Result<Option<T>, Error<()>>
Takes ownership of the current value, leaving the cell uninitialized.
Returns Err if the cell is refered or in critical section.
sourcepub fn take(&self) -> Result<Option<T>, Error<()>>
pub fn take(&self) -> Result<Option<T>, Error<()>>
Takes ownership of the current value, leaving the cell uninitialized.
Returns Err is unreachable.
Notice: Spin
pub unsafe fn peek(&self) -> &T
sourcepub fn try_get(&self) -> Result<Ref<'_, T>, Error<()>>
pub fn try_get(&self) -> Result<Ref<'_, T>, Error<()>>
Tries to get a reference to the value of the Cell.
Returns Err if the cell is uninitialized, in operation or in critical section.
sourcepub fn get(&self) -> Result<Ref<'_, T>, Error<()>>
pub fn get(&self) -> Result<Ref<'_, T>, Error<()>>
Tries to get a reference to the value of the Cell.
Returns Err if the cell is uninitialized.
Notice: Spin
sourcepub fn try_set(&self, value: T) -> Result<(), Error<T>>
pub fn try_set(&self, value: T) -> Result<(), Error<T>>
Sets the value of the Cell to the argument value.
Returns Err if the value is refered, initialized or in critical section.
sourcepub fn set(&self, value: T) -> Result<(), Error<T>>
pub fn set(&self, value: T) -> Result<(), Error<T>>
Sets the value of the Cell to the argument value.
Returns Err if the value is refered, initialized.
Notice: Spin
sourcepub fn try_replace(&self, value: T) -> Result<Option<T>, Error<T>>
pub fn try_replace(&self, value: T) -> Result<Option<T>, Error<T>>
Replaces the contained value with value, and returns the old contained value.
Returns Err if the value is refered or in critical section.
sourcepub fn replace(&self, value: T) -> Result<Option<T>, Error<T>>
pub fn replace(&self, value: T) -> Result<Option<T>, Error<T>>
Replaces the contained value with value, and returns the old contained value.
Returns Err is unreachable.
Notice: Spin
sourcepub fn get_or_try_init(&self, value: T) -> Result<Ref<'_, T>, Error<T>>
pub fn get_or_try_init(&self, value: T) -> Result<Ref<'_, T>, Error<T>>
Tries to get a reference to the value of the Cell.
Returns Err if the cell is in critical section.
sourcepub fn get_or_init(&self, value: T) -> Ref<'_, T>
pub fn get_or_init(&self, value: T) -> Ref<'_, T>
Tries to get a reference to the value of the Cell.
Notice: Spin
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Cell<T>
impl<T> Send for Cell<T> where
T: Send,
impl<T> Sync for Cell<T> where
T: Sync,
impl<T> Unpin for Cell<T> where
T: Unpin,
impl<T> UnwindSafe for Cell<T> where
T: 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