[−][src]Struct index_ext::int::TryIndex
An indexing adaptor for TryInto
.
This transparent wrapper allows any type to function as an index as long as it is fallibly
convertible to a usize
. Contrary to the simple integer types, the implementation of
get_unchecked
methods will not unsafely assume that the conversion itself can't fail, only
that the resulting index is in-bounds.
Separating this from the main IndexType
solves a coherence problem that would occurs when
instantiating it with ranges: The standard library is permitted to add new impls of
TryInto<usize>
, for example even for Range<usize>
. Hence, these two impls would overlap
but we would like the first to have another return type than the second. The indirection
over this type means that our impls are only generic for TryIndex<T>
instead and do not
overlap.
Trait Implementations
impl<T: Clone> Clone for TryIndex<T>
[src]
fn clone(&self) -> TryIndex<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Copy> Copy for TryIndex<T>
[src]
impl<T: Debug> Debug for TryIndex<T>
[src]
impl<T: Default> Default for TryIndex<T>
[src]
impl<T: Eq> Eq for TryIndex<T>
[src]
impl<T: Hash> Hash for TryIndex<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T, U> Index<TryIndex<T>> for [U] where
T: TryInto<usize> + IndexSealed,
T::Error: Into<TryFromIntError>,
[src]
T: TryInto<usize> + IndexSealed,
T::Error: Into<TryFromIntError>,
impl<T, U> IndexMut<TryIndex<T>> for [U] where
T: TryInto<usize> + IndexSealed,
T::Error: Into<TryFromIntError>,
[src]
T: TryInto<usize> + IndexSealed,
T::Error: Into<TryFromIntError>,
impl<T, U> IntSliceIndex<[U]> for TryIndex<T> where
T: TryInto<usize>,
T::Error: Into<TryFromIntError>,
[src]
T: TryInto<usize>,
T::Error: Into<TryFromIntError>,
impl<T: Ord> Ord for TryIndex<T>
[src]
fn cmp(&self, other: &TryIndex<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<TryIndex<T>> for TryIndex<T>
[src]
impl<T: PartialOrd> PartialOrd<TryIndex<T>> for TryIndex<T>
[src]
fn partial_cmp(&self, other: &TryIndex<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &TryIndex<T>) -> bool
[src]
fn le(&self, other: &TryIndex<T>) -> bool
[src]
fn gt(&self, other: &TryIndex<T>) -> bool
[src]
fn ge(&self, other: &TryIndex<T>) -> bool
[src]
impl<T> StructuralEq for TryIndex<T>
[src]
impl<T> StructuralPartialEq for TryIndex<T>
[src]
Auto Trait Implementations
impl<T> Send for TryIndex<T> where
T: Send,
T: Send,
impl<T> Sync for TryIndex<T> where
T: Sync,
T: Sync,
impl<T> Unpin for TryIndex<T> where
T: Unpin,
T: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,