pub trait IndexableTuple<const INDEX: usize>: NonEmptyTuple {
type Value;
// Required methods
fn get(&self) -> &Self::Value;
fn get_mut(&mut self) -> &mut Self::Value;
fn into_index(self) -> Self::Value;
}Expand description
Tuples that can be indexed. Implemented for sized tuples of arity 1 to 32.
Required Associated Types§
Required Methods§
Sourcefn get(&self) -> &Self::Value
fn get(&self) -> &Self::Value
Returns a reference to the value at the given index.
§Examples
let tuple = (1, 2, 3);
assert_eq!(&2, IndexableTuple::<1>::get(&tuple));Sourcefn get_mut(&mut self) -> &mut Self::Value
fn get_mut(&mut self) -> &mut Self::Value
Returns a mutable reference to the value at the given index.
§Examples
let mut tuple = (1, 2, 3);
assert_eq!(&mut 2, IndexableTuple::<1>::get_mut(&mut tuple));Sourcefn into_index(self) -> Self::Value
fn into_index(self) -> Self::Value
Consumes this tuple and returns the value at the given index.
§Examples
let tuple = (1, 2, 3);
assert_eq!(2, IndexableTuple::<1>::into_index(tuple));Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.