[][src]Struct index_ext::tag::Idx

pub struct Idx<I, Tag> { /* fields omitted */ }

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 [Len] struct.

Implementations

impl<T, I> Idx<I, T>[src]

pub fn into_inner(self) -> I[src]

Get the inner index.

impl<T> Idx<usize, T>[src]

#[must_use = "Returns a new index"]pub fn saturating_sub(self, sub: usize) -> Self[src]

Create a smaller index.

#[must_use = "Returns a new index"]pub fn truncate(self, min: usize) -> Self[src]

Bound the index from above.

#[must_use = "Returns a new index"]pub fn into_range(self) -> Idx<Range<usize>, T>[src]

Return the range that contains this element.

#[must_use = "Returns a new index"]pub fn into_len(self) -> Len<T>[src]

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

#[must_use = "Returns a new index"]pub fn into_end(self) -> NonZeroLen<T>[src]

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.

impl<T> Idx<RangeTo<usize>, T>[src]

#[must_use = "Returns a new index"]pub fn into_end(self) -> Len<T>[src]

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

#[must_use = "Returns a new index"]pub fn range_from(self, from: Len<T>) -> Option<Idx<Range<usize>, T>>[src]

Construct an index starting at an element.

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

impl<T> Idx<RangeFrom<usize>, T>[src]

#[must_use = "Returns a new index"]pub fn into_start(self) -> Len<T>[src]

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

#[must_use = "Returns a new index"]pub fn range_to(self, to: Len<T>) -> Option<Idx<Range<usize>, T>>[src]

Construct an index up to at an element.

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

impl<T> Idx<Range<usize>, T>[src]

#[must_use = "Returns a new index"]pub fn into_start(self) -> Len<T>[src]

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

#[must_use = "Returns a new index"]pub fn into_end(self) -> Len<T>[src]

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

Trait Implementations

impl<I: Clone, Tag: Clone> Clone for Idx<I, Tag>[src]

impl<I: Copy, Tag: Copy> Copy for Idx<I, Tag>[src]

impl<T: Tag, E, I, '_> Index<Idx<I, T>> for Ref<'_, E, T> where
    I: SliceIndex<[E]>, 
[src]

type Output = I::Output

The returned type after indexing.

impl<T: Tag, E, I, '_> Index<Idx<I, T>> for Mut<'_, E, T> where
    I: SliceIndex<[E]>, 
[src]

type Output = I::Output

The returned type after indexing.

impl<T: Tag, E, I, '_> IndexMut<Idx<I, T>> for Mut<'_, E, T> where
    I: SliceIndex<[E]>, 
[src]

Auto Trait Implementations

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.