Trait typed_index_collections::TiSliceIndex
source · [−]pub trait TiSliceIndex<K, V>: Sealed<K> {
type Output: ?Sized;
fn get(self, slice: &TiSlice<K, V>) -> Option<&Self::Output>;
fn get_mut(self, slice: &mut TiSlice<K, V>) -> Option<&mut Self::Output>;
unsafe fn get_unchecked(self, slice: &TiSlice<K, V>) -> &Self::Output;
unsafe fn get_unchecked_mut(
self,
slice: &mut TiSlice<K, V>
) -> &mut Self::Output;
fn index(self, slice: &TiSlice<K, V>) -> &Self::Output;
fn index_mut(self, slice: &mut TiSlice<K, V>) -> &mut Self::Output;
}
Expand description
A helper trait used for indexing operations.
This trait is implemented for K
, Range<K>
, RangeTo<K>
, RangeFrom<K>
,
RangeInclusive<K>
and RangeToInclusive<K>
.
The RangeFull<K>
trait is not currently supported.
Trait implementations are only forwards to standard Rust slice
operations.
Required Associated Types
Required Methods
Returns a shared reference to the output at this location, if in bounds.
Returns a mutable reference to the output at this location, if in bounds.
sourceunsafe fn get_unchecked(self, slice: &TiSlice<K, V>) -> &Self::Output
unsafe fn get_unchecked(self, slice: &TiSlice<K, V>) -> &Self::Output
Returns a shared reference to the output at this location, without performing any bounds checking. Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.
sourceunsafe fn get_unchecked_mut(self, slice: &mut TiSlice<K, V>) -> &mut Self::Output
unsafe fn get_unchecked_mut(self, slice: &mut TiSlice<K, V>) -> &mut Self::Output
Returns a mutable reference to the output at this location, without performing any bounds checking. Calling this method with an out-of-bounds index is undefined behavior even if the resulting reference is not used.
Returns a shared reference to the output at this location, panicking if out of bounds.