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> Idx<usize, T>
impl<T> Idx<usize, T>
sourcepub fn saturating_sub(self, sub: usize) -> Self
pub fn saturating_sub(self, sub: usize) -> Self
Create a smaller index.
sourcepub fn into_range(self) -> Idx<Range<usize>, T>
pub fn into_range(self) -> Idx<Range<usize>, T>
Return the range that contains this element.
sourcepub fn into_end(self) -> NonZeroLen<T>
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.
Trait Implementations§
impl<I: Copy, Tag: Copy> Copy for Idx<I, Tag>
Auto Trait Implementations§
impl<I, Tag> RefUnwindSafe for Idx<I, Tag>where
I: RefUnwindSafe,
Tag: RefUnwindSafe,
impl<I, Tag> Send for Idx<I, Tag>
impl<I, Tag> Sync for Idx<I, Tag>
impl<I, Tag> Unpin for Idx<I, Tag>
impl<I, Tag> UnwindSafe for Idx<I, Tag>where
I: UnwindSafe,
Tag: 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