Struct indexmap::set::Slice

source ·
#[repr(transparent)]
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>

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

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) -> (&Self, &Self)

Divides one slice into two at an index.

Panics if index > len.

source

pub fn split_first(&self) -> Option<(&T, &Self)>

Returns the first value and the rest of the slice, or None if it is empty.

source

pub fn split_last(&self) -> Option<(&T, &Self)>

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> Clone for Box<Slice<T>>

source§

fn clone(&self) -> Self

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

source§

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

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

impl<T> Default for &Slice<T>

source§

fn default() -> Self

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

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

source§

fn default() -> Self

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

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

source§

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

Converts to this type from the input type.
source§

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

source§

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

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>)) -> &Self::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>) -> &Self::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>) -> &Self::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) -> &Self::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>) -> &Self::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>) -> &Self::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>) -> &Self::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) -> &Self::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) -> Self::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) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

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

source§

fn cmp(&self, other: &Self) -> Ordering

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

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

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<T: PartialOrd> PartialOrd<Slice<T>> for Slice<T>

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<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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

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

source§

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

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

impl<Q, K> Equivalent<K> for Qwhere 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.