Struct Cell

Source
pub struct Cell<T, const MP: usize, const MC: usize> { /* private fields */ }

Implementations§

Source§

impl<T, const MP: usize, const MC: usize> Cell<T, MP, MC>

Source

pub const fn new() -> Self

Source

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

Source§

impl<T: Unpin, const MP: usize, const MC: usize> Cell<T, MP, MC>

Source

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

Source

pub fn try_get(&self) -> Result<Ref<'_, T, MP, MC>, Error<()>>

Tries to get a reference to the value of the Cell.

Returns Err if the cell is uninitialized or in critical section.

Source

pub fn get(&self) -> Get<'_, T, MP, MC>

Tries to get a reference to the value of the Cell.

Returns Err if the cell is uninitialized.

Source

pub fn try_set(&self, val: 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, val: T) -> Set<'_, T, MP, MC>

Sets the value of the Cell to the argument value.

Returns Err if the value is refered or initialized.

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) -> Take<'_, T, MP, MC>

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

Source

pub fn try_replace(&self, val: 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, val: T) -> Replace<'_, T, MP, MC>

Replaces the contained value with value, and returns the old contained value.

Auto Trait Implementations§

§

impl<T, const MP: usize, const MC: usize> !Freeze for Cell<T, MP, MC>

§

impl<T, const MP: usize, const MC: usize> !RefUnwindSafe for Cell<T, MP, MC>

§

impl<T, const MP: usize, const MC: usize> Send for Cell<T, MP, MC>
where T: Send,

§

impl<T, const MP: usize, const MC: usize> Sync for Cell<T, MP, MC>
where T: Sync,

§

impl<T, const MP: usize, const MC: usize> Unpin for Cell<T, MP, MC>
where T: Unpin,

§

impl<T, const MP: usize, const MC: usize> UnwindSafe for Cell<T, MP, MC>
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.