Struct Cell

Source
pub struct Cell<T> { /* private fields */ }

Implementations§

Source§

impl<T> Cell<T>

Source

pub const fn new() -> Self

Source

pub const fn new_with(init: T) -> Self

Source

pub fn is_initialized(&self) -> bool

Source

pub fn ref_num(&self) -> Result<usize, MemoryState>

Source

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.

Source

pub fn take(&self) -> Result<Option<T>, Error<()>>

Takes ownership of the current value, leaving the cell uninitialized.

Returns Err is unreachable.

Notice: Spin

Source

pub unsafe fn peek(&self) -> &T

Source

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.

Source

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

Source

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.

Source

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

Source

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.

Source

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

Source

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.

Source

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§

Source§

impl<'a, T: Debug> Debug for Cell<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for Cell<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for Cell<T>

§

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§

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