Trait Index
pub trait Index<Idx: ?Sized>
Used for indexing operations (container[index]) in immutable contexts.
container[index] is actually syntactic sugar for *container.index(index),
but only when used as an immutable value. If a mutable value is requested,
IndexMut is used instead. This allows nice things such as
let value = v[index] if the type of value implements Copy.
Examples
The following example implements Index on a read-only NucleotideCount
container, enabling individual counts to be retrieved with index syntax.
use Index;
let nucleotide_count = NucleotideCount ;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Associated Types
type Output: ?Sized;The returned type after indexing.
Required Methods
fn index(&self, index: Idx) -> &Self::OutputPerforms the indexing (
container[index]) operation.Panics
May panic if the index is out of bounds.
Implementors
impl Index<Range<usize>> for Wtf8impl Index<RangeFrom<usize>> for CStrimpl Index<RangeFrom<usize>> for CStrimpl Index<RangeFrom<usize>> for Wtf8impl Index<RangeFull> for Wtf8impl Index<RangeTo<usize>> for Wtf8impl<I> Index<I> for ByteStr where I: SliceIndex<ByteStr>,impl<I> Index<I> for str where I: ~const SliceIndex<str>,impl<I, T, const N: usize> Index<I> for Simd<T, N> where T: SimdElement, I: SliceIndex<[T]>,impl<T, I> Index<I> for [T] where I: ~const SliceIndex<[T]>,impl<T, I, const N: usize> Index<I> for [T; N] where [T]: ~const Index<I>,