#[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>

source

pub fn len(&self) -> usize

Return the number of elements in the set slice.

source

pub fn is_empty(&self) -> bool

Returns true if the set slice contains no elements.

source

pub fn get_index(&self, index: usize) -> Option<&T>

Get a value by index.

Valid indices are 0 <= index < self.len()

source

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

source

pub fn first(&self) -> Option<&T>

Get the first value.

source

pub fn last(&self) -> Option<&T>

Get the last value.

source

pub fn split_at(&self, index: usize) -> (&Slice<T>, &Slice<T>)

Divides one slice into two at an index.

Panics if index > len.

source

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.

source

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.

source

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

Return an iterator over the values of the set slice.

Trait Implementations§

source§

impl<T> Clone for Box<Slice<T>>
where T: Clone,

source§

fn clone(&self) -> Box<Slice<T>>

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<T> Debug for Slice<T>
where T: Debug,

source§

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

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

impl<T> Default for &Slice<T>

source§

fn default() -> &Slice<T>

Returns the “default value” for a type. Read more
source§

impl<T> Default for Box<Slice<T>>

source§

fn default() -> Box<Slice<T>>

Returns the “default value” for a type. Read more
source§

impl<T> From<&Slice<T>> for Box<Slice<T>>
where T: Copy,

source§

fn from(slice: &Slice<T>) -> Box<Slice<T>>

Converts to this type from the input type.
source§

impl<T> Hash for Slice<T>
where T: Hash,

source§

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

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

impl<T> Index<(Bound<usize>, Bound<usize>)> for Slice<T>

§

type Output = Slice<T>

The returned type after indexing.
source§

fn index( &self, range: (Bound<usize>, Bound<usize>) ) -> &<Slice<T> as Index<(Bound<usize>, Bound<usize>)>>::Output

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

impl<T> Index<Range<usize>> for Slice<T>

§

type Output = Slice<T>

The returned type after indexing.
source§

fn index( &self, range: Range<usize> ) -> &<Slice<T> as Index<Range<usize>>>::Output

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

impl<T> Index<RangeFrom<usize>> for Slice<T>

§

type Output = Slice<T>

The returned type after indexing.
source§

fn index( &self, range: RangeFrom<usize> ) -> &<Slice<T> as Index<RangeFrom<usize>>>::Output

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

impl<T> Index<RangeFull> for Slice<T>

§

type Output = Slice<T>

The returned type after indexing.
source§

fn index(&self, range: RangeFull) -> &<Slice<T> as Index<RangeFull>>::Output

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

impl<T> Index<RangeInclusive<usize>> for Slice<T>

§

type Output = Slice<T>

The returned type after indexing.
source§

fn index( &self, range: RangeInclusive<usize> ) -> &<Slice<T> as Index<RangeInclusive<usize>>>::Output

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

impl<T> Index<RangeTo<usize>> for Slice<T>

§

type Output = Slice<T>

The returned type after indexing.
source§

fn index( &self, range: RangeTo<usize> ) -> &<Slice<T> as Index<RangeTo<usize>>>::Output

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

impl<T> Index<RangeToInclusive<usize>> for Slice<T>

§

type Output = Slice<T>

The returned type after indexing.
source§

fn index( &self, range: RangeToInclusive<usize> ) -> &<Slice<T> as Index<RangeToInclusive<usize>>>::Output

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

impl<T> Index<usize> for Slice<T>

§

type Output = T

The returned type after indexing.
source§

fn index(&self, index: usize) -> &<Slice<T> as Index<usize>>::Output

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

impl<'a, T> IntoIterator for &'a Slice<T>

§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
§

type Item = &'a T

The type of the elements being iterated over.
source§

fn into_iter(self) -> <&'a Slice<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> IntoIterator for Box<Slice<T>>

§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
§

type Item = T

The type of the elements being iterated over.
source§

fn into_iter(self) -> <Box<Slice<T>> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> Ord for Slice<T>
where T: Ord,

source§

fn cmp(&self, other: &Slice<T>) -> Ordering

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

impl<T> PartialEq for Slice<T>
where T: PartialEq,

source§

fn eq(&self, other: &Slice<T>) -> 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<T> PartialOrd for Slice<T>
where T: PartialOrd,

source§

fn partial_cmp(&self, other: &Slice<T>) -> 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<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,

Serialize this value into the given Serde serializer. Read more
source§

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more