#[repr(transparent)]pub struct Slice<T> {
pub(crate) entries: [Bucket<T, ()>],
}
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
.
Fields§
§entries: [Bucket<T, ()>]
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>(&self, range: R) -> Option<&Slice<T>>where
R: RangeBounds<usize>,
pub fn get_range<R>(&self, range: R) -> Option<&Slice<T>>where
R: RangeBounds<usize>,
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) -> (&Slice<T>, &Slice<T>)
pub fn split_at(&self, index: usize) -> (&Slice<T>, &Slice<T>)
Divides one slice into two at an index.
Panics if index > len
.
sourcepub fn split_first(&self) -> Option<(&T, &Slice<T>)>
pub fn split_first(&self) -> Option<(&T, &Slice<T>)>
Returns the first value and the rest of the slice,
or None
if it is empty.
sourcepub fn split_last(&self) -> Option<(&T, &Slice<T>)>
pub fn split_last(&self) -> Option<(&T, &Slice<T>)>
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 for Slice<T>where
T: PartialEq,
impl<T> PartialEq for Slice<T>where
T: PartialEq,
source§impl<T> PartialOrd for Slice<T>where
T: PartialOrd,
impl<T> PartialOrd for Slice<T>where
T: PartialOrd,
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,
impl<T> Serialize for Slice<T>where
T: Serialize,
Serializes a set::Slice
as an ordered sequence.
Requires crate feature "serde"
source§fn serialize<Se>(
&self,
serializer: Se
) -> Result<<Se as Serializer>::Ok, <Se as Serializer>::Error>where
Se: Serializer,
fn serialize<Se>(
&self,
serializer: Se
) -> Result<<Se as Serializer>::Ok, <Se as Serializer>::Error>where
Se: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T> Eq for Slice<T>where
T: Eq,
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> 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.