pub trait Get<Idx>: Collection {
type Output: ?Sized;
// Required method
fn get(&self, index: Idx) -> Option<&Self::Output>;
// Provided methods
fn get_or_panic(&self, index: Idx) -> &Self::Output { ... }
unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output { ... }
fn is_index_valid(&self, index: Idx) -> bool { ... }
fn is_index_invalid(&self, index: Idx) -> bool { ... }
fn contains(&self, index: Idx) -> bool { ... }
}Expand description
The collection have a quick way to access each element, where the index is copyable
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn get_or_panic(&self, index: Idx) -> &Self::Output
fn get_or_panic(&self, index: Idx) -> &Self::Output
Returns a reference to the value.
Sourceunsafe fn get_unchecked(&self, index: Idx) -> &Self::Output
unsafe fn get_unchecked(&self, index: Idx) -> &Self::Output
Returns a reference to the value.
Sourcefn is_index_valid(&self, index: Idx) -> bool
fn is_index_valid(&self, index: Idx) -> bool
True if get(index) return Some, false otherwise.
Sourcefn is_index_invalid(&self, index: Idx) -> bool
fn is_index_invalid(&self, index: Idx) -> bool
True if get(index) return None, false otherwise.