Struct ArrayCell

Source
pub struct ArrayCell<T, const N: usize> { /* private fields */ }
Expand description

A Cell<[T; N]>-like type that has some additional slice-like API.

This type dereferences to SliceCell<T>.

This type can be converted to and from Cell<[T; N]> and [Cell<T>; N] in several ways.

Implementations§

Source§

impl<T, const N: usize> ArrayCell<T, N>

Source

pub const fn as_std_ref(&self) -> &Cell<[T; N]>

View this ArrayCell as a Cell of an array of N elements.

Source

pub const fn as_std_transposed_ref(&self) -> &[Cell<T>; N]

View this ArrayCell as an array of N Cells.

Source

pub const fn from_std_ref(std: &Cell<[T; N]>) -> &Self

View a Cell of an array of N elements as an ArrayCell.

Source

pub const fn from_std_transposed_ref(std: &[Cell<T>; N]) -> &Self

View an array of N Cells as an ArrayCell.

Source

pub fn as_std_mut(&mut self) -> &mut Cell<[T; N]>

View this ArrayCell as a Cell of an array of N elements.

Source

pub fn as_std_transposed_mut(&mut self) -> &mut [Cell<T>; N]

View this ArrayCell as an array of N Cells.

Source

pub fn from_std_mut(std: &mut Cell<[T; N]>) -> &mut Self

View a Cell of an array of N elements as an ArrayCell.

Source

pub fn from_std_transposed_mut(std: &mut [Cell<T>; N]) -> &mut Self

View an array of N Cells as an ArrayCell.

Source§

impl<T, const N: usize> ArrayCell<T, N>

Source

pub fn into_std_boxed(self: Box<Self>) -> Box<Cell<[T; N]>>

Available on crate feature alloc only.

View this ArrayCell as a Cell of an array of N elements.

Source

pub fn into_std_transposed_boxed(self: Box<Self>) -> Box<[Cell<T>; N]>

Available on crate feature alloc only.

View this ArrayCell as an array of N Cells.

Source

pub fn from_std_boxed(std: Box<Cell<[T; N]>>) -> Box<Self>

Available on crate feature alloc only.

View a Cell of an array of N elements as an ArrayCell.

Source

pub fn from_std_transposed_boxed(std: Box<[Cell<T>; N]>) -> Box<Self>

Available on crate feature alloc only.

View an array of N Cells as an ArrayCell.

Source

pub fn new_boxed(inner: Box<[T; N]>) -> Box<Self>

Available on crate feature alloc only.

Wraps a boxed array in an ArrayCell.

Source

pub fn into_inner_boxed(self: Box<Self>) -> Box<[T; N]>

Available on crate feature alloc only.

Unwaps a boxed ArrayCell into an array.

Source§

impl<T, const N: usize> ArrayCell<T, N>

Source

pub fn into_std_rc(self: Rc<Self>) -> Rc<Cell<[T; N]>>

Available on crate feature rc only.

View this ArrayCell as a Cell of an array of N elements.

Source

pub fn into_std_transposed_rc(self: Rc<Self>) -> Rc<[Cell<T>; N]>

Available on crate feature rc only.

View this ArrayCell as an array of N Cells.

Source

pub fn from_std_rc(std: Rc<Cell<[T; N]>>) -> Rc<Self>

Available on crate feature rc only.

View a Cell of an array of N elements as an ArrayCell.

Source

pub fn from_std_transposed_rc(std: Rc<[Cell<T>; N]>) -> Rc<Self>

Available on crate feature rc only.

View an array of N Cells as an ArrayCell.

Source

pub fn try_new_rc(inner: Rc<[T; N]>) -> Result<Rc<Self>, Rc<[T; N]>>

Available on crate feature rc only.

Wraps a reference-counted array in an ArrayCell, if it is uniquely owned.

Source

pub fn try_into_inner_rc(self: Rc<Self>) -> Result<Rc<[T; N]>, Rc<Self>>

Available on crate feature rc only.

Unwraps a reference-counted ArrayCell into an array, if it is uniquely owned.

Source

pub fn unsize_rc(self: Rc<Self>) -> Rc<SliceCell<T>>

Available on crate feature rc only.

Replacement for From impl, since Rc is not fundamental.

Source§

impl<T, const N: usize> ArrayCell<T, N>

Source

pub fn as_ptr(&self) -> *mut [T; N]

Returns a raw pointer to the underlying data in this ArrayCell.

Source

pub fn into_inner(self) -> [T; N]

Consumes the ArrayCell, returning the wrapped array.

Source

pub fn new(inner: [T; N]) -> Self

Wraps an array in an ArrayCell.

Source

pub fn as_mut(&mut self) -> &mut [T; N]

Unwraps a uniquely borrowed ArrayCell into an array.

Source

pub fn from_mut(inner: &mut [T; N]) -> &mut Self

Wraps a uniquely borrowed array in an ArrayCell.

Source

pub fn get<I: SliceCellIndex<Self>>(&self, idx: I) -> Option<&I::Output>

Returns a reference to an element or subslice depending on the type of index.

See slice::get.

Source

pub fn get_mut<I: SliceCellIndex<Self>>( &mut self, idx: I, ) -> Option<&mut I::Output>

Returns a mutable reference to an element or subslice depending on the type of index.

See also slice::get_mut.

Source

pub const fn len(&self) -> usize

Returns the length of the ArrayCell.

Trait Implementations§

Source§

impl<T, const N: usize> AsMut<SliceCell<T>> for ArrayCell<T, N>

Source§

fn as_mut(&mut self) -> &mut SliceCell<T>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T, const N: usize> AsRef<SliceCell<T>> for ArrayCell<T, N>

Source§

fn as_ref(&self) -> &SliceCell<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, T: 'a> Default for &'a ArrayCell<T, 0>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, T: 'a> Default for &'a mut ArrayCell<T, 0>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, T, const N: usize> From<&'a ArrayCell<T, N>> for &'a SliceCell<T>

Source§

fn from(value: &'a ArrayCell<T, N>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T, const N: usize> From<&'a mut ArrayCell<T, N>> for &'a mut SliceCell<T>

Source§

fn from(value: &'a mut ArrayCell<T, N>) -> Self

Converts to this type from the input type.
Source§

impl<'a, T, const N: usize> IntoIterator for &'a ArrayCell<T, N>

Source§

type Item = &'a Cell<T>

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Cell<T>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T, const N: usize> IntoIterator for &'a mut ArrayCell<T, N>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T, const N: usize> TryFrom<&'a SliceCell<T>> for &'a ArrayCell<T, N>

Source§

type Error = &'a SliceCell<T>

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a SliceCell<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, T, const N: usize> TryFrom<&'a mut SliceCell<T>> for &'a mut ArrayCell<T, N>

Source§

type Error = &'a mut SliceCell<T>

The type returned in the event of a conversion error.
Source§

fn try_from(value: &'a mut SliceCell<T>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a, T, const N: usize> TryFrom<Box<SliceCell<T>>> for Box<ArrayCell<T, N>>

Available on crate feature alloc only.
Source§

type Error = Box<SliceCell<T>>

The type returned in the event of a conversion error.
Source§

fn try_from(value: Box<SliceCell<T>>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T: Send, const N: usize> Send for ArrayCell<T, N>

Auto Trait Implementations§

§

impl<T, const N: usize> !Freeze for ArrayCell<T, N>

§

impl<T, const N: usize> !RefUnwindSafe for ArrayCell<T, N>

§

impl<T, const N: usize> !Sync for ArrayCell<T, N>

§

impl<T, const N: usize> Unpin for ArrayCell<T, N>
where T: Unpin,

§

impl<T, const N: usize> UnwindSafe for ArrayCell<T, N>
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.