IdCell

Struct IdCell 

Source
pub struct IdCell<V: ?Sized, T> {
    pub token: T,
    /* private fields */
}
Expand description

A thread-safe shared mutable type that can be allows references into it’s interior (unlike Cell) without returning guards (unlike RefCell, Mutex, or RwLock).

Fields§

§token: T

The token that identifies this IdCell

Implementations§

Source§

impl<V, T: Trivial> IdCell<V, T>

Source

pub fn new(value: V) -> Self

Create a new IdCell

Source§

impl<V, T> IdCell<V, T>

Source

pub const fn with_token(value: V, token: T) -> Self

Create a new IdCell with the given token

Source

pub fn into_raw_parts(self) -> (V, T)

Decompose the given IdCell into a value-token pair

Source§

impl<V: ?Sized, T> IdCell<V, T>

Source

pub fn as_ptr(&self) -> *mut V

Get a pointer into the interior of the IdCell

Source

pub fn get_mut(&mut self) -> &mut V

Get a mutable reference into the interior of the IdCell

Source§

impl<V: ?Sized, T: Trivial> IdCell<V, T>

Source

pub fn from_mut(value: &mut V) -> &mut Self

Create a new IdCell from a reference to a given type

Note: this requires the token have the same layout as () and be Trivial. The Trivial requirement is handled by traits, but if you try and call this with a token that has a different layout from (), from_mut this will panic.

Source§

impl<V, T: Trivial> IdCell<[V], T>

Source

pub fn as_slice_of_cells(&self) -> &[IdCell<V, T>]

Convert a cell of a slice to a slice of cells

Note: this requires the token have the same layout as () and be Trivial. The Trivial requirement is handled by traits, but if you try and call this with a token that has a different layout from (), as_slice_of_cells this will panic.

Source

pub fn as_slice_of_cells_mut(&mut self) -> &mut [IdCell<V, T>]

Convert a cell of a slice to a slice of cells

Note: this requires the token have the same layout as () and be Trivial. The Trivial requirement is handled by traits, but if you try and call this with a token that has a different layout from (), as_slice_of_cells_mut this will panic.

Auto Trait Implementations§

§

impl<V, T> !Freeze for IdCell<V, T>

§

impl<V, T> !RefUnwindSafe for IdCell<V, T>

§

impl<V, T> Send for IdCell<V, T>
where T: Send, V: Send + ?Sized,

§

impl<V, T> Sync for IdCell<V, T>
where T: Sync, V: Send + Sync,

§

impl<V, T> Unpin for IdCell<V, T>
where T: Unpin, V: Unpin + ?Sized,

§

impl<V, T> UnwindSafe for IdCell<V, T>
where T: UnwindSafe, V: UnwindSafe + ?Sized,

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.