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
.
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 const fn as_std_transposed_ref(&self) -> &[Cell<T>]
pub const fn as_std_transposed_ref(&self) -> &[Cell<T>]
Sourcepub const fn from_std_transposed_ref(std: &[Cell<T>]) -> &Self
pub const fn from_std_transposed_ref(std: &[Cell<T>]) -> &Self
Sourcepub fn as_std_transposed_mut(&mut self) -> &mut [Cell<T>]
pub fn as_std_transposed_mut(&mut self) -> &mut [Cell<T>]
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>
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.
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 get<I: SliceCellIndex<Self>>(&self, idx: I) -> Option<&I::Output>
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
.
Sourcepub fn get_mut<I: SliceCellIndex<Self>>(
&mut self,
idx: I,
) -> Option<&mut I::Output>
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
.
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 T, &mut SliceCell<T>)>
pub fn split_first_mut(&mut self) -> Option<(&mut 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 T, &mut SliceCell<T>)>
pub fn split_last_mut(&mut self) -> Option<(&mut 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, likely using a memcpy.
The length of src must be the same as self.
Sourcepub fn copy_from(&self, src: &SliceCell<T>)where
T: Copy,
pub fn copy_from(&self, src: &SliceCell<T>)where
T: Copy,
Copies all elements from src into self, likely using a memmove.
The length of src must be the same as self.
self
and src
may overlap.
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,
Available on crate feature alloc
only.
pub fn take_into_vec(&self) -> Vec<T>where
T: Default,
alloc
only.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,
Available on crate feature alloc
only.
pub fn copy_into_vec(&self) -> Vec<T>where
T: Copy,
alloc
only.Copy all elements from this SliceCell
into a newly allocated Vec<T>
.
pub fn replace_with_vec(&self, src: Vec<T>)
alloc
only.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 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>
Source§impl<T, const N: usize> SliceCell<[T; N]>
impl<T, const N: usize> SliceCell<[T; N]>
Sourcepub fn flatten(&self) -> &SliceCell<T>
pub fn flatten(&self) -> &SliceCell<T>
Flattens a &SliceCell<[T; N]>
into a &SliceCell<T>
.
§Panics
Panics if the length of the resulting SliceCell
would overflow a usize
.
See also [slice::flatten
].
Sourcepub fn flatten_mut(&mut self) -> &mut SliceCell<T>
pub fn flatten_mut(&mut self) -> &mut SliceCell<T>
Flattens a &mut SliceCell<[T; N]>
into a &mut SliceCell<T>
.
§Panics
Panics if the length of the resulting SliceCell
would overflow a usize
.
See also [slice::flatten_mut
].
Trait Implementations§
Source§impl AsyncWrite for &SliceCell<u8>
Available on crate features std
and tokio
only.
impl AsyncWrite for &SliceCell<u8>
std
and tokio
only.Source§fn poll_write(
self: Pin<&mut Self>,
_: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Self>, _: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf
into the object. Read moreSource§fn poll_flush(
self: Pin<&mut Self>,
_: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, _: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_shutdown(
self: Pin<&mut Self>,
_: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut Self>, _: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write
, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read moreSource§impl<'a, T, const N: usize> From<Box<ArrayCell<T, N>>> for Box<SliceCell<T>>
Available on crate feature alloc
only.
impl<'a, T, const N: usize> From<Box<ArrayCell<T, N>>> for Box<SliceCell<T>>
alloc
only.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>
Available on crate feature std
only.
impl Read for &SliceCell<u8>
std
only.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>
Available on crate feature std
only.
impl Write for &SliceCell<u8>
std
only.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
)