Trait flatk::Get [−][src]
pub trait Get<'a, I> {
type Output;
fn get(&self, idx: I) -> Option<Self::Output>;
fn at(&self, idx: I) -> Self::Output { ... }
unsafe fn at_unchecked(&self, idx: I) -> Self::Output { ... }
}
Expand description
An index trait for collection types.
Here 'i
indicates the lifetime of the input while 'o
indicates that of
the output.
Associated Types
Required methods
Provided methods
Return a value at the given index. This is provided as the checked
version of get
that will panic if the equivalent get
call is None
,
which typically means that the given index is out of bounds.
Panics
This function will panic if self.get(idx)
returns None
.
unsafe fn at_unchecked(&self, idx: I) -> Self::Output
unsafe fn at_unchecked(&self, idx: I) -> Self::Output
Return a value at the given index.
Safety
This is provided as the unchecked version of get
that has undefined
behavior when the index is out of bounds.
The default implementation simply calls at
which will panic, but custom
implementors may omit bounds checks entirely.