Trait IndexRange

Source
pub trait IndexRange<Idx>:
    Index<Range<Idx>, Output = <Self as Index<RangeFull>>::Output>
    + Index<RangeTo<Idx>, Output = <Self as Index<RangeFull>>::Output>
    + Index<RangeFrom<Idx>, Output = <Self as Index<RangeFull>>::Output>
    + Index<RangeFull>
    + Sealed { }
Expand description

Shorthand trait for collections which offer consistent, immutable slicing.

Here, “consistent” means that indexing is implemented for all of the Range types from the standard library, and the type returned by each of the slices is always the same.

Currently, because inclusive ranges are unstable, and ranges starting with an exclusive bound don’t exist, this trait can’t be implemented for anything other than str and [T]. Hopefully, this will change in the future.

Implementors§

Source§

impl<T, Idx> IndexRange<Idx> for T
where T: Index<Range<Idx>, Output = <T as Index<RangeFull>>::Output> + Index<RangeTo<Idx>, Output = <T as Index<RangeFull>>::Output> + Index<RangeFrom<Idx>, Output = <T as Index<RangeFull>>::Output> + Index<RangeFull> + Sealed + ?Sized,