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<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 moreimpl<T: Eq> Eq for Slice<T>
Auto Trait Implementations§
impl<T> Freeze for Slice<T>where
T: Freeze,
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