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>

source

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.

source

pub fn iter(&self) -> Iter<'_, A, N>

Get an iterator over references to the items in the slice in order.

source

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

source

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.

source

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>

source§

fn get(&self, index: usize) -> Option<&A>

Get a reference to the value at a given index.

source§

fn first(&self) -> Option<&Self::Output>

Get a reference to the first element in the array.
source§

fn last(&self) -> Option<&Self::Output>

Get a reference to the last element in the array.
source§

fn binary_search_by<F>(&self, compare: F) -> Result<usize, usize>
where F: FnMut(&Self::Output) -> Ordering,

Perform a binary search using a comparator function.
source§

fn binary_search_by_key<K, F>( &self, key: &K, extract: F ) -> Result<usize, usize>
where F: FnMut(&Self::Output) -> K, K: Ord,

Perform a binary search using a key and a key extractor function.
source§

fn is_sorted_by<F>(&self, compare: F) -> bool
where F: FnMut(&Self::Output, &Self::Output) -> Option<Ordering>,

Test whether the array is sorted using a comparator function.
source§

fn is_sorted_by_key<K, F>(&self, extract: F) -> bool
where F: FnMut(&Self::Output) -> K, K: PartialOrd,

Test whether the array is sorted using a key extractor function.
source§

impl<'a, A: 'a, const N: usize> Clone for Slice<'a, A, N>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, A: Debug + 'a, const N: usize> Debug for Slice<'a, A, N>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

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

Converts to this type from the input type.
source§

impl<'a, A: 'a, const N: usize> HasLength for Slice<'a, A, N>

source§

fn len(&self) -> usize

Get the length of the slice.

source§

fn is_empty(&self) -> bool

Return whether the data structure is empty.
source§

impl<'a, A: Hash + 'a, const N: usize> Hash for Slice<'a, A, N>

source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, A: 'a, const N: usize> Index<usize> for Slice<'a, A, N>

§

type Output = A

The returned type after indexing.
source§

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

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

impl<'a, A: 'a, const N: usize> Into<Slice<'a, A, N>> for SliceMut<'a, A, N>

source§

fn into(self) -> Slice<'a, A, N>

Converts this type into the (usually inferred) input type.
source§

impl<'a, A: 'a, const N: usize> IntoIterator for &'a Slice<'a, A, N>

§

type Item = &'a A

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, A, N>

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, A: Ord + 'a, const N: usize> Ord for Slice<'a, A, N>

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<'a, A: PartialEq + 'a, const N: usize> PartialEq<RingBuffer<A, N>> for Slice<'a, A, N>

source§

fn eq(&self, other: &RingBuffer<A, N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A: PartialEq + 'a, S, const N: usize> PartialEq<S> for Slice<'a, A, N>
where S: Borrow<[A]>,

source§

fn eq(&self, other: &S) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A, const N: usize> PartialEq<Slice<'_, A, N>> for RingBuffer<A, N>
where A: PartialEq,

source§

fn eq(&self, other: &Slice<'_, A, N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A: PartialEq + 'a, const N: usize> PartialEq<Slice<'a, A, N>> for SliceMut<'a, A, N>

source§

fn eq(&self, other: &Slice<'a, A, N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A: PartialEq + 'a, const N: usize> PartialEq<SliceMut<'a, A, N>> for Slice<'a, A, N>

source§

fn eq(&self, other: &SliceMut<'a, A, N>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A: PartialEq + 'a, const N: usize> PartialEq for Slice<'a, A, N>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A: PartialOrd + 'a, const N: usize> PartialOrd for Slice<'a, A, N>

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, A: Eq + 'a, const N: usize> Eq for Slice<'a, A, N>

Auto Trait Implementations§

§

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> 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
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.