Struct index_ext::tag::Idx

source ·
pub struct Idx<I, Tag> { /* private fields */ }
Expand description

A valid index for all slices of the same length.

While this has a generic parameter, you can only instantiate this type for specific types through one of the constructors of a corresponding [Prefix] struct.

Implementations§

source§

impl<T, I> Idx<I, T>

source

pub fn into_inner(self) -> I

Get the inner index.

source

pub fn with_tag<NewT>(self, larger: TagLessEq<T, NewT>) -> Idx<I, NewT>

Interpret this as an index into a larger slice.

source§

impl<T> Idx<usize, T>

source

pub fn saturating_sub(self, sub: usize) -> Self

Create a smaller index.

source

pub fn truncate(self, min: usize) -> Self

Bound the index from above.

source

pub fn into_range(self) -> Idx<Range<usize>, T>

Return the range that contains this element.

source

pub fn into_len(self) -> Prefix<T>

Get a length up-to, not including this index.

source

pub fn into_end(self) -> NonZeroLen<T>

Get the length beyond this index.

Unlike turning it into a range and using its end, this guarantees that the end is non-zero as it knows the range not to be empty.

source§

impl<T> Idx<RangeTo<usize>, T>

source

pub fn into_end(self) -> Prefix<T>

Get a length up-to, not including this index.

source

pub fn range_from(self, from: Prefix<T>) -> Option<Idx<Range<usize>, T>>

Construct an index starting at an element.

This method return Some when from does not exceed the end index.

source§

impl<T> Idx<RangeFrom<usize>, T>

source

pub fn into_start(self) -> Prefix<T>

Get a length up-to, not including this index.

source

pub fn range_to(self, to: Prefix<T>) -> Option<Idx<Range<usize>, T>>

Construct an index up to at an element.

This method return Some when to does not exceed the end index.

source§

impl<T> Idx<Range<usize>, T>

source

pub fn into_start(self) -> Prefix<T>

Get a length up-to, not including this index.

source

pub fn into_end(self) -> Prefix<T>

Get a length up-to, not including this index.

Trait Implementations§

source§

impl<I: Clone, Tag: Clone> Clone for Idx<I, Tag>

source§

fn clone(&self) -> Idx<I, Tag>

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: Tag, E, I> Index<Idx<I, T>> for Slice<E, T>
where I: SliceIndex<[E]>,

§

type Output = <I as SliceIndex<[E]>>::Output

The returned type after indexing.
source§

fn index(&self, idx: Idx<I, T>) -> &Self::Output

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

impl<T: Tag, E, I> IndexMut<Idx<I, T>> for Slice<E, T>
where I: SliceIndex<[E]>,

source§

fn index_mut(&mut self, idx: Idx<I, T>) -> &mut Self::Output

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

impl<I: Copy, Tag: Copy> Copy for Idx<I, Tag>

Auto Trait Implementations§

§

impl<I, Tag> RefUnwindSafe for Idx<I, Tag>

§

impl<I, Tag> Send for Idx<I, Tag>
where I: Send, Tag: Send,

§

impl<I, Tag> Sync for Idx<I, Tag>
where I: Sync, Tag: Sync,

§

impl<I, Tag> Unpin for Idx<I, Tag>
where I: Unpin, Tag: Unpin,

§

impl<I, Tag> UnwindSafe for Idx<I, Tag>
where I: UnwindSafe, Tag: 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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.