Struct SliceCell

Source
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>

Source

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

View this SliceCell as a Cell of a slice.

Source

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

View this SliceCell as a slice of Cells.

Source

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

View a Cell of a slice as a SliceCell.

Source

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

View a slice of Cells as a SliceCell.

Source

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

View this SliceCell as a Cell of a slice.

Source

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

View this SliceCell as a slice of Cells.

Source

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

View a Cell of a slice as a SliceCell.

Source

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

View a slice of Cell as a SliceCell.

Source§

impl<T> SliceCell<T>

Source

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

View this SliceCell as a Cell of a slice.

Source

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

View this SliceCell as a slice of Cells.

Source

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

View a Cell of a slice as a SliceCell.

Source

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

View a slice of Cells as a SliceCell.

Source

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

Unwraps an owned boxed SliceCell into a slice.

Source

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

Wraps an owned boxed slice in a SliceCell.

Source§

impl<T> SliceCell<T>

Source

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

View this SliceCell as a Cell of a slice.

Source

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

View this SliceCell as a slice of Cells.

Source

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

View a Cell of a slice as a SliceCell.

Source

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

Source

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.

Source

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

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

Source§

impl<T> SliceCell<T>

Source

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

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

Source

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

Unwraps a uniquely borrowed SliceCell into a slice.

Source

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

Wraps a uniquely borrowed slice in a SliceCell.

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 SliceCell.

Source

pub fn split_at(&self, mid: usize) -> (&SliceCell<T>, &SliceCell<T>)

Divide one SliceCell into two at an index.

Panics if mid > self.len().

See slice::split_at

Source

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().

See slice::split_at_mut

Source

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.

See slice::split_first

Source

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.

See slice::split_first_mut

Source

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.

See slice::split_last

Source

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.

See slice::split_last_mut

Source

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.

See slice::copy_from_slice.

Source

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.

Source

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.

See slice::copy_from_slice.

Source

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

Source

pub fn take_into_vec(&self) -> Vec<T>
where T: Default,

Available on crate feature alloc only.

Take all elements from this SliceCell into a newly allocated Vec<T>, leaving T::default() in each cell.

Source

pub fn copy_into_slice(&self, dst: &mut [T])
where T: Copy,

Copy all elements from this SliceCell into a mutable slice.

Source

pub fn copy_into_vec(&self) -> Vec<T>
where T: Copy,

Available on crate feature alloc only.

Copy all elements from this SliceCell into a newly allocated Vec<T>.

Source

pub fn replace_with_vec(&self, src: Vec<T>)

Available on crate feature alloc only.
Source

pub fn swap_with_slice(&self, val: &mut [T])

Source

pub fn swap(&self, a: usize, b: usize)

Swaps two elements in the slice.

See <[T]>::swap.

Source

pub fn rotate_left(&self, mid: usize)

Source

pub fn rotate_right(&self, mid: usize)

Source

pub fn fill(&self, val: T)
where T: Clone,

Fills self with elements by cloning value.

See also: <[T]>::fill.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn iter(&self) -> Iter<'_, Cell<T>>

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

Source§

impl<T, const N: usize> SliceCell<[T; N]>

Source

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].

Source

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<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> AsMut<SliceCell<T>> for SliceCell<T>

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<T> AsRef<SliceCell<T>> for SliceCell<T>

Source§

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

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

impl AsyncRead for &SliceCell<u8>

Available on crate features std and tokio only.
Source§

fn poll_read( self: Pin<&mut Self>, _cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>

Attempts to read from the AsyncRead into buf. Read more
Source§

impl AsyncWrite for &SliceCell<u8>

Available on crate features std and tokio only.
Source§

fn poll_write( self: Pin<&mut Self>, _: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>

Attempt to write bytes from buf into the object. Read more
Source§

fn poll_flush( self: Pin<&mut Self>, _: &mut Context<'_>, ) -> Poll<Result<(), Error>>

Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

fn poll_shutdown( self: Pin<&mut Self>, _: &mut Context<'_>, ) -> Poll<Result<(), Error>>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Like poll_write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

Determines if this writer has an efficient poll_write_vectored implementation. Read more
Source§

impl<'a, T: 'a> Default for &'a SliceCell<T>

Source§

fn default() -> Self

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

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

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> From<Box<ArrayCell<T, N>>> for Box<SliceCell<T>>

Available on crate feature alloc only.
Source§

fn from(value: Box<ArrayCell<T, N>>) -> Self

Converts to this type from the input type.
Source§

impl<T, I: SliceCellIndex<Self>> Index<I> for SliceCell<T>

Source§

type Output = <I as SliceCellIndex<SliceCell<T>>>::Output

The returned type after indexing.
Source§

fn index(&self, index: I) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T, I: SliceCellIndex<Self>> IndexMut<I> for SliceCell<T>

Source§

fn index_mut(&mut self, index: I) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a SliceCell<T>

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> IntoIterator for &'a mut SliceCell<T>

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 Read for &SliceCell<u8>

Available on crate feature std only.
Source§

fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.36.0 · Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
1.6.0 · Source§

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>

Reads the exact number of bytes required to fill buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. 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 Write for &SliceCell<u8>

Available on crate feature std only.
Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
Source§

impl<T: Send> Send for SliceCell<T>

Auto Trait Implementations§

§

impl<T> !Freeze for SliceCell<T>

§

impl<T> !RefUnwindSafe for SliceCell<T>

§

impl<T> !Sized for SliceCell<T>

§

impl<T> !Sync for SliceCell<T>

§

impl<T> Unpin for SliceCell<T>
where T: Unpin,

§

impl<T> UnwindSafe for SliceCell<T>
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