Struct slice_cell::ArrayCell
source · #[repr(transparent)]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>.
Under the assume_cell_layout cargo feature, 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>
impl<T, const N: usize> ArrayCell<T, N>
sourcepub fn as_std_ref(&self) -> &Cell<[T; N]>
pub fn as_std_ref(&self) -> &Cell<[T; N]>
sourcepub fn as_std_transposed_ref(&self) -> &[Cell<T>; N]
pub fn as_std_transposed_ref(&self) -> &[Cell<T>; N]
sourcepub fn from_std_ref(std: &Cell<[T; N]>) -> &Self
pub fn from_std_ref(std: &Cell<[T; N]>) -> &Self
sourcepub fn from_std_transposed_ref(std: &[Cell<T>; N]) -> &Self
pub fn from_std_transposed_ref(std: &[Cell<T>; N]) -> &Self
sourcepub fn as_std_mut(&mut self) -> &mut Cell<[T; N]>
pub fn as_std_mut(&mut self) -> &mut Cell<[T; N]>
sourcepub fn as_std_transposed_mut(&mut self) -> &mut [Cell<T>; N]
pub fn as_std_transposed_mut(&mut self) -> &mut [Cell<T>; N]
sourcepub fn from_std_mut(std: &mut Cell<[T; N]>) -> &mut Self
pub fn from_std_mut(std: &mut Cell<[T; N]>) -> &mut Self
source§impl<T, const N: usize> ArrayCell<T, N>
impl<T, const N: usize> ArrayCell<T, N>
source§impl<T, const N: usize> ArrayCell<T, N>
impl<T, const N: usize> ArrayCell<T, N>
source§impl<T, const N: usize> ArrayCell<T, N>
impl<T, const N: usize> ArrayCell<T, N>
sourcepub fn as_ptr(&self) -> *mut [T; N]
pub fn as_ptr(&self) -> *mut [T; N]
Returns a raw pointer to the underlying data in this ArrayCell.
sourcepub fn into_inner(self) -> [T; N]
pub fn into_inner(self) -> [T; N]
sourcepub fn try_new_rc(inner: Rc<[T; N]>) -> Result<Rc<Self>, Rc<[T; N]>>
pub fn try_new_rc(inner: Rc<[T; N]>) -> Result<Rc<Self>, Rc<[T; N]>>
Wraps a reference-counted array in an ArrayCell, if it is uniquely owned.
sourcepub fn try_into_inner_rc(self: Rc<Self>) -> Result<Rc<[T; N]>, Rc<Self>>
pub fn try_into_inner_rc(self: Rc<Self>) -> Result<Rc<[T; N]>, Rc<Self>>
Unwraps a reference-counted ArrayCell into an array, if it is uniquely owned.
sourcepub fn unsize_rc(self: Rc<Self>) -> Rc<SliceCell<T>>
pub fn unsize_rc(self: Rc<Self>) -> Rc<SliceCell<T>>
Replacement for From impl, since Rc is not fundamental
Methods from Deref<Target = SliceCell<T>>§
sourcepub fn as_ptr(&self) -> *mut [T]
pub fn as_ptr(&self) -> *mut [T]
Returns a raw pointer to the underlying data in this SliceCell.
sourcepub fn try_into_inner_rc(self: Rc<Self>) -> Result<Rc<[T]>, Rc<Self>>
pub fn try_into_inner_rc(self: Rc<Self>) -> Result<Rc<[T]>, Rc<Self>>
Unwraps a reference-counted SliceCell into an slice, if it is uniquely owned.
sourcepub fn split_at_mut(
&mut self,
mid: usize
) -> (&mut SliceCell<T>, &mut SliceCell<T>)
pub fn split_at_mut(
&mut self,
mid: usize
) -> (&mut SliceCell<T>, &mut SliceCell<T>)
Divide one mutable SliceCell into two at an index.
Panics if mid > self.len().
sourcepub fn split_first(&self) -> Option<(&Cell<T>, &SliceCell<T>)>
pub fn split_first(&self) -> Option<(&Cell<T>, &SliceCell<T>)>
Returns the first and all the rest of the elements of the SliceCell, or None if it is empty.
sourcepub fn split_first_mut(&mut self) -> Option<(&mut Cell<T>, &mut SliceCell<T>)>
pub fn split_first_mut(&mut self) -> Option<(&mut Cell<T>, &mut SliceCell<T>)>
Returns the first and all the rest of the elements of the SliceCell, or None if it is empty.
sourcepub fn split_last(&self) -> Option<(&Cell<T>, &SliceCell<T>)>
pub fn split_last(&self) -> Option<(&Cell<T>, &SliceCell<T>)>
Returns the last and all the rest of the elements of the SliceCell, or None if it is empty.
sourcepub fn split_last_mut(&mut self) -> Option<(&mut Cell<T>, &mut SliceCell<T>)>
pub fn split_last_mut(&mut self) -> Option<(&mut Cell<T>, &mut SliceCell<T>)>
Returns the last and all the rest of the elements of the SliceCell, or None if it is empty.
sourcepub fn copy_from_slice(&self, src: &[T])where
T: Copy,
pub fn copy_from_slice(&self, src: &[T])where
T: Copy,
Copies all elements from src into self, using a memcpy.
The length of src must be the same as self.
sourcepub fn clone_from_slice(&self, src: &[T])where
T: Clone,
pub fn clone_from_slice(&self, src: &[T])where
T: Clone,
Clones all elements from src into self.
The length of src must be the same as self.
sourcepub fn take_into_slice(&self, dst: &mut [T])where
T: Default,
pub fn take_into_slice(&self, dst: &mut [T])where
T: Default,
Take all elements from this SliceCell into a mutable slice, leaving T::default() in each cell
sourcepub fn take_into_vec(&self) -> Vec<T>where
T: Default,
pub fn take_into_vec(&self) -> Vec<T>where
T: Default,
Take all elements from this SliceCell into a newly allocated Vec<T>, leaving T::default() in each cell.
sourcepub fn copy_into_slice(&self, dst: &mut [T])where
T: Copy,
pub fn copy_into_slice(&self, dst: &mut [T])where
T: Copy,
Copy all elements from this SliceCell into a mutable slice.
sourcepub fn copy_into_vec(&self) -> Vec<T>where
T: Copy,
pub fn copy_into_vec(&self) -> Vec<T>where
T: Copy,
Copy all elements from this SliceCell into a newly allocated Vec<T>.
pub fn replace_with_vec(&self, src: Vec<T>)
pub fn swap_with_slice(&self, val: &mut [T])
sourcepub fn swap(&self, a: usize, b: usize)
pub fn swap(&self, a: usize, b: usize)
Swaps two elements in the slice.
See <[T]>::swap.
sourcepub fn rotate_left(&self, mid: usize)
pub fn rotate_left(&self, mid: usize)
sourcepub fn rotate_right(&self, mid: usize)
pub fn rotate_right(&self, mid: usize)
sourcepub fn fill(&self, val: T)where
T: Clone,
pub fn fill(&self, val: T)where
T: Clone,
Fills self with elements by cloning value.
See also: <[T]>::fill.
sourcepub fn fill_with<F>(&self, f: F)where
F: FnMut() -> T,
pub fn fill_with<F>(&self, f: F)where
F: FnMut() -> T,
Fills self with elements returned by calling a closure repeatedly.
See also: <[T]>::fill_with.
sourcepub fn try_size_rc<const N: usize>(
self: Rc<Self>
) -> Result<Rc<ArrayCell<T, N>>, Rc<Self>>
pub fn try_size_rc<const N: usize>(
self: Rc<Self>
) -> Result<Rc<ArrayCell<T, N>>, Rc<Self>>
Replacement for TryFrom impl, since Rc is not fundamental
sourcepub fn as_chunks<const N: usize>(&self) -> (&SliceCell<[T; N]>, &Self)
pub fn as_chunks<const N: usize>(&self) -> (&SliceCell<[T; N]>, &Self)
N should not be 0.
Splits the slice into a slice of N-element arrays, starting at the beginning of the slice, and a remainder slice with length strictly less than N.
sourcepub fn as_rchunks<const N: usize>(&self) -> (&Self, &SliceCell<[T; N]>)
pub fn as_rchunks<const N: usize>(&self) -> (&Self, &SliceCell<[T; N]>)
N should not be 0.
Splits the slice into a slice of N-element arrays, starting at the end of the slice, and a remainder slice with length strictly less than N.
sourcepub fn as_chunks_mut<const N: usize>(
&mut self
) -> (&mut SliceCell<[T; N]>, &mut Self)
pub fn as_chunks_mut<const N: usize>(
&mut self
) -> (&mut SliceCell<[T; N]>, &mut Self)
N should not be 0.
Splits the slice into a slice of N-element arrays, starting at the beginning of the slice, and a remainder slice with length strictly less than N.
sourcepub fn as_rchunks_mut<const N: usize>(
&mut self
) -> (&mut Self, &mut SliceCell<[T; N]>)
pub fn as_rchunks_mut<const N: usize>(
&mut self
) -> (&mut Self, &mut SliceCell<[T; N]>)
N should not be 0.
Splits the slice into a slice of N-element arrays, starting at the end of the slice, and a remainder slice with length strictly less than N.