Trait std::ops::Index[src]
pub trait Index<Index, Result> {
fn index<Index, Result>(&self, index: &Index) -> Result;
}The Index trait is used to specify the functionality of indexing operations
like arr[idx].
Example
A trivial implementation of Index. When Foo[Foo] happens, it ends up
calling index, and therefore, main prints Indexing!.
struct Foo; impl Index<Foo, Foo> for Foo { fn index(&self, _rhs: &Foo) -> Foo { println!("Indexing!"); *self } } fn main() { Foo[Foo]; }
Required Methods
fn index<Index, Result>(&self, index: &Index) -> Result
The method for the indexing (Foo[Bar]) operation