Trait Index
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: TraitBound { trait_: Path { path: "Sized", id: Id(12), args: None }, generic_params: [], modifier: Maybe }The returned type after indexing.
Required Methods
fn index(self: &Self, index: Idx) -> &<Self as >::OutputPerforms the indexing (
container[index]) operation.Panics
May panic if the index is out of bounds.