pub struct SliceMut<'a, A, const N: usize> { /* private fields */ }
Expand description

An indexable representation of a mutable subset of a RingBuffer.

Implementations§

source§

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

source

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

Downgrade this slice into a non-mutable slice.

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 unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut A

Get an unchecked mutable 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 iter_mut(&mut self) -> IterMut<'_, A, N>

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

source

pub fn slice<R: RangeBounds<usize>>(self, range: R) -> SliceMut<'a, A, N>

Create a subslice of this slice.

This consumes the slice. Because the slice works like a mutable reference, you can only have one slice over a given subset of a RingBuffer at any one time, so that’s just how it’s got to be.

source

pub fn split_at(self, index: usize) -> (SliceMut<'a, A, N>, SliceMut<'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 SliceMut<'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> ArrayMut for SliceMut<'a, A, N>

source§

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

Get a mutable reference to the value at a given index.

source§

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

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

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

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

fn map_pair<F, A>(&mut self, index1: usize, index2: usize, f: F) -> A
where F: FnMut(&mut Self::Output, &mut Self::Output) -> A,

Get mutable references to the elements at two indexes and call a function on them. Read more
source§

impl<'a, A: Debug + 'a, const N: usize> Debug for SliceMut<'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 mut RingBuffer<A, N>> for SliceMut<'a, A, N>

source§

fn from(buffer: &'a mut RingBuffer<A, N>) -> Self

Converts to this type from the input type.
source§

impl<'a, A: 'a, const N: usize> HasLength for SliceMut<'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 SliceMut<'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 SliceMut<'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> IndexMut<usize> for SliceMut<'a, A, N>

source§

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

Performs the mutable 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, 'b, A: 'a, const N: usize> IntoIterator for &'a SliceMut<'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, 'b, A: 'a, const N: usize> IntoIterator for &'a mut SliceMut<'a, A, N>

§

type Item = &'a mut A

The type of the elements being iterated over.
§

type IntoIter = IterMut<'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 SliceMut<'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 SliceMut<'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 SliceMut<'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, 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, const N: usize> PartialEq<SliceMut<'_, A, N>> for RingBuffer<A, N>
where A: PartialEq,

source§

fn eq(&self, other: &SliceMut<'_, 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 SliceMut<'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 SliceMut<'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 SliceMut<'a, A, N>

Auto Trait Implementations§

§

impl<'a, A, const N: usize> RefUnwindSafe for SliceMut<'a, A, N>
where A: RefUnwindSafe,

§

impl<'a, A, const N: usize> Send for SliceMut<'a, A, N>
where A: Send,

§

impl<'a, A, const N: usize> Sync for SliceMut<'a, A, N>
where A: Sync,

§

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

§

impl<'a, A, const N: usize> !UnwindSafe for SliceMut<'a, A, N>

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