pub struct Slice<T> { /* private fields */ }
Expand description
A dynamically-sized slice of values in an IndexSet
.
This supports indexed operations much like a [T]
slice,
but not any hashed operations on the values.
Unlike IndexSet
, Slice
does consider the order for PartialEq
and Eq
, and it also implements PartialOrd
, Ord
, and Hash
.
Implementations§
source§impl<T> Slice<T>
impl<T> Slice<T>
sourcepub fn get_index(&self, index: usize) -> Option<&T>
pub fn get_index(&self, index: usize) -> Option<&T>
Get a value by index.
Valid indices are 0 <= index < self.len()
sourcepub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Self>
pub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Self>
Returns a slice of values in the given range of indices.
Valid indices are 0 <= index < self.len()
sourcepub fn split_at(&self, index: usize) -> (&Self, &Self)
pub fn split_at(&self, index: usize) -> (&Self, &Self)
Divides one slice into two at an index.
Panics if index > len
.
sourcepub fn split_first(&self) -> Option<(&T, &Self)>
pub fn split_first(&self) -> Option<(&T, &Self)>
Returns the first value and the rest of the slice,
or None
if it is empty.
sourcepub fn split_last(&self) -> Option<(&T, &Self)>
pub fn split_last(&self) -> Option<(&T, &Self)>
Returns the last value and the rest of the slice,
or None
if it is empty.
Trait Implementations§
source§impl<'a, T> IntoIterator for &'a Slice<T>
impl<'a, T> IntoIterator for &'a Slice<T>
source§impl<T> IntoIterator for Box<Slice<T>>
impl<T> IntoIterator for Box<Slice<T>>
source§impl<'a, T> IntoParallelIterator for &'a Slice<T>where
T: Sync,
Available on crate feature rayon
only.
impl<'a, T> IntoParallelIterator for &'a Slice<T>where
T: Sync,
Available on crate feature
rayon
only.source§impl<T> IntoParallelIterator for Box<Slice<T>>where
T: Send,
Available on crate feature rayon
only.
impl<T> IntoParallelIterator for Box<Slice<T>>where
T: Send,
Available on crate feature
rayon
only.§type Iter = IntoParIter<T>
type Iter = IntoParIter<T>
The parallel iterator type that will be created.
source§fn into_par_iter(self) -> Self::Iter
fn into_par_iter(self) -> Self::Iter
Converts
self
into a parallel iterator. Read moresource§impl<T: PartialEq> PartialEq for Slice<T>
impl<T: PartialEq> PartialEq for Slice<T>
source§impl<T: PartialOrd> PartialOrd for Slice<T>
impl<T: PartialOrd> PartialOrd for Slice<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl<T> Serialize for Slice<T>where
T: Serialize,
Available on crate feature serde
only.
impl<T> Serialize for Slice<T>where
T: Serialize,
Available on crate feature
serde
only.Serializes a set::Slice
as an ordered sequence.
impl<T: Eq> Eq for Slice<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Slice<T>where
T: RefUnwindSafe,
impl<T> Send for Slice<T>where
T: Send,
impl<T> !Sized for Slice<T>
impl<T> Sync for Slice<T>where
T: Sync,
impl<T> Unpin for Slice<T>where
T: Unpin,
impl<T> UnwindSafe for Slice<T>where
T: UnwindSafe,
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
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<'data, I> IntoParallelRefIterator<'data> for I
impl<'data, I> IntoParallelRefIterator<'data> for I
§type Iter = <&'data I as IntoParallelIterator>::Iter
type Iter = <&'data I as IntoParallelIterator>::Iter
The type of the parallel iterator that will be returned.
§type Item = <&'data I as IntoParallelIterator>::Item
type Item = <&'data I as IntoParallelIterator>::Item
The type of item that the parallel iterator will produce.
This will typically be an
&'data T
reference type.