Struct slice_cell::SliceCell
source · #[repr(transparent)]pub struct SliceCell<T> { /* private fields */ }Expand description
A Cell<[T]>-like type that has some additional slice-like API.
References to this type can be gotten from dereferencing an ArrayCell<T, N>, or using from_mut.
Under the assume_cell_layout cargo feature, this type can be converted to and from Cell<[T]> and [Cell<T>] in several ways.
Implementations§
source§impl<T> SliceCell<T>
impl<T> SliceCell<T>
sourcepub fn as_std_transposed_mut(&mut self) -> &mut [Cell<T>]
pub fn as_std_transposed_mut(&mut self) -> &mut [Cell<T>]
pub fn from_std_transposed_mut(std: &mut [Cell<T>]) -> &mut Self
source§impl<T> SliceCell<T>
impl<T> SliceCell<T>
source§impl<T> SliceCell<T>
impl<T> SliceCell<T>
sourcepub fn into_std_transposed_rc(self: Rc<Self>) -> Rc<[Cell<T>]>
pub fn into_std_transposed_rc(self: Rc<Self>) -> Rc<[Cell<T>]>
pub fn from_std_transposed_rc(std: Rc<[Cell<T>]>) -> Rc<Self>
source§impl<T> SliceCell<T>
impl<T> 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_new_rc(inner: Rc<[T]>) -> Result<Rc<Self>, Rc<[T]>>
pub fn try_new_rc(inner: Rc<[T]>) -> Result<Rc<Self>, Rc<[T]>>
Wraps a reference-counted slice in a SliceCell, if it is uniquely owned.
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.
pub fn iter(&self) -> Iter<'_, Cell<T>>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Trait Implementations§
source§impl<'a, T> IntoIterator for &'a SliceCell<T>
impl<'a, T> IntoIterator for &'a SliceCell<T>
source§impl<'a, T> IntoIterator for &'a mut SliceCell<T>
impl<'a, T> IntoIterator for &'a mut SliceCell<T>
source§impl Read for &SliceCell<u8>
impl Read for &SliceCell<u8>
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>
buf. Read more1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read moresource§impl Write for &SliceCell<u8>
impl Write for &SliceCell<u8>
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)