pub struct Slice<'a, A, const N: usize> { /* private fields */ }
Expand description
An indexable representation of a subset of a RingBuffer
.
Implementations§
Source§impl<'a, A: 'a, const N: usize> Slice<'a, A, N>
impl<'a, A: 'a, const N: usize> Slice<'a, A, N>
Sourcepub unsafe fn get_unchecked(&self, index: usize) -> &A
pub unsafe fn get_unchecked(&self, index: usize) -> &A
Get an unchecked reference to the value at the given index.
§Safety
You must ensure the index is not out of bounds.
Sourcepub fn iter(&self) -> Iter<'_, A, N> ⓘ
pub fn iter(&self) -> Iter<'_, A, N> ⓘ
Get an iterator over references to the items in the slice in order.
Sourcepub fn slice<R: RangeBounds<usize>>(self, range: R) -> Slice<'a, A, N>
pub fn slice<R: RangeBounds<usize>>(self, range: R) -> Slice<'a, A, N>
Create a subslice of this slice.
This consumes the slice. To create a subslice without consuming it,
clone it first: my_slice.clone().slice(1..2)
.
Sourcepub fn split_at(self, index: usize) -> (Slice<'a, A, N>, Slice<'a, A, N>)
pub fn split_at(self, index: usize) -> (Slice<'a, A, N>, Slice<'a, A, N>)
Split the slice into two subslices at the given index.
Sourcepub fn to_owned(&self) -> RingBuffer<A, N>where
A: Clone,
pub fn to_owned(&self) -> RingBuffer<A, N>where
A: Clone,
Construct a new RingBuffer
by copying the elements in this slice.
Trait Implementations§
Source§impl<'a, A: 'a, const N: usize> Array for Slice<'a, A, N>
impl<'a, A: 'a, const N: usize> Array for Slice<'a, A, N>
Source§fn contains(&self, target: &Self::Output) -> bool
fn contains(&self, target: &Self::Output) -> bool
Return true if an element equivalent to
target
exists in the array.Source§fn binary_search(&self, target: &Self::Output) -> Result<usize, usize>
fn binary_search(&self, target: &Self::Output) -> Result<usize, usize>
Perform a binary search for
target
.Source§fn binary_search_by<F>(&self, compare: F) -> Result<usize, usize>
fn binary_search_by<F>(&self, compare: F) -> Result<usize, usize>
Perform a binary search using a comparator function.
Source§fn binary_search_by_key<K, F>(
&self,
key: &K,
extract: F,
) -> Result<usize, usize>
fn binary_search_by_key<K, F>( &self, key: &K, extract: F, ) -> Result<usize, usize>
Perform a binary search using a key and a key extractor function.
Source§fn is_sorted_by<F>(&self, compare: F) -> bool
fn is_sorted_by<F>(&self, compare: F) -> bool
Test whether the array is sorted using a comparator function.
Source§fn is_sorted_by_key<K, F>(&self, extract: F) -> bool
fn is_sorted_by_key<K, F>(&self, extract: F) -> bool
Test whether the array is sorted using a key extractor function.
Source§fn starts_with(&self, slice: &[Self::Output]) -> bool
fn starts_with(&self, slice: &[Self::Output]) -> bool
Test whether the array starts with the elements in
slice
.Source§impl<'a, A: 'a, const N: usize> From<&'a RingBuffer<A, N>> for Slice<'a, A, N>
impl<'a, A: 'a, const N: usize> From<&'a RingBuffer<A, N>> for Slice<'a, A, N>
Source§fn from(buffer: &'a RingBuffer<A, N>) -> Self
fn from(buffer: &'a RingBuffer<A, N>) -> Self
Converts to this type from the input type.
Source§impl<'a, A: 'a, const N: usize> IntoIterator for &'a Slice<'a, A, N>
impl<'a, A: 'a, const N: usize> IntoIterator for &'a Slice<'a, A, N>
Source§impl<'a, A: Ord + 'a, const N: usize> Ord for Slice<'a, A, N>
impl<'a, A: Ord + 'a, const N: usize> Ord for Slice<'a, A, N>
Source§impl<'a, A: PartialEq + 'a, const N: usize> PartialEq<Slice<'a, A, N>> for SliceMut<'a, A, N>
impl<'a, A: PartialEq + 'a, const N: usize> PartialEq<Slice<'a, A, N>> for SliceMut<'a, A, N>
Source§impl<'a, A: PartialEq + 'a, const N: usize> PartialEq<SliceMut<'a, A, N>> for Slice<'a, A, N>
impl<'a, A: PartialEq + 'a, const N: usize> PartialEq<SliceMut<'a, A, N>> for Slice<'a, A, N>
Source§impl<'a, A: PartialOrd + 'a, const N: usize> PartialOrd for Slice<'a, A, N>
impl<'a, A: PartialOrd + 'a, const N: usize> PartialOrd for Slice<'a, A, N>
impl<'a, A: Eq + 'a, const N: usize> Eq for Slice<'a, A, N>
Auto Trait Implementations§
impl<'a, A, const N: usize> Freeze for Slice<'a, A, N>
impl<'a, A, const N: usize> RefUnwindSafe for Slice<'a, A, N>where
A: RefUnwindSafe,
impl<'a, A, const N: usize> Send for Slice<'a, A, N>where
A: Sync,
impl<'a, A, const N: usize> Sync for Slice<'a, A, N>where
A: Sync,
impl<'a, A, const N: usize> Unpin for Slice<'a, A, N>
impl<'a, A, const N: usize> UnwindSafe for Slice<'a, A, N>where
A: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more