Trait stride::StrideIndex
source · pub unsafe trait StrideIndex<T: ?Sized>: Sealed {
type Output: ?Sized;
fn get(self, stride: &T) -> Option<&Self::Output>;
fn get_mut(self, stride: &mut T) -> Option<&mut Self::Output>;
unsafe fn get_unchecked(self, stride: *const T) -> *const Self::Output;
unsafe fn get_unchecked_mut(self, stride: *mut T) -> *mut Self::Output;
fn index(self, stride: &T) -> &Self::Output;
fn index_mut(self, stride: &mut T) -> &mut Self::Output;
}
Expand description
A helper trait used for indexing operations.
This is the Stride
version of SliceIndex
.
You should not use or implement this trait directly but instead use the
corresponding methods on Stride
.
Safety
Implementations of this trait have to promise that if the argument
to get_(mut_)unchecked
is a safe reference, then so is the result.
Required Associated Types
Required Methods
sourcefn get(self, stride: &T) -> Option<&Self::Output>
fn get(self, stride: &T) -> Option<&Self::Output>
Returns a shared reference to the output at this location, if in bounds.
sourcefn get_mut(self, stride: &mut T) -> Option<&mut Self::Output>
fn get_mut(self, stride: &mut T) -> Option<&mut Self::Output>
Returns a mutable reference to the output at this location, if in bounds.
sourceunsafe fn get_unchecked(self, stride: *const T) -> *const Self::Output
unsafe fn get_unchecked(self, stride: *const T) -> *const Self::Output
Returns a shared reference to the output at this location, without performing any bounds checking.
Safety
Calling this method with an out-of-bounds index or a dangling stride
pointer is undefined behavior even if the resulting reference is not
used.
sourceunsafe fn get_unchecked_mut(self, stride: *mut T) -> *mut Self::Output
unsafe fn get_unchecked_mut(self, stride: *mut T) -> *mut Self::Output
Returns a mutable reference to the output at this location, without performing any bounds checking.
Safety
Calling this method with an out-of-bounds index or a dangling stride
pointer is undefined behavior even if the resulting reference is not
used.