pub unsafe trait SlicePointerIndex<T>{
type Output: ?Sized;
// Required methods
fn get(self, slice: *const T) -> Option<*const Self::Output>;
fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>;
unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output;
unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output;
fn index(self, slice: *const T) -> *const Self::Output;
fn index_mut(self, slice: *mut T) -> *mut Self::Output;
}
Expand description
A helper trait used for indexing operations, which is modeled after the SliceIndex trait from the Rust core library, but which promises not to take a reference to the underlying slice.
§Safety
Implementations of this trait have to promise that:
- If the argument to get_(mut_)unchecked is a safe pointer, then so is the result.
- The pointers may not be dereferenced (both pointers given as arguments as well as the returned pointers).
Required Associated Types§
Required Methods§
Sourcefn get(self, slice: *const T) -> Option<*const Self::Output>
fn get(self, slice: *const T) -> Option<*const Self::Output>
Returns a shared pointer to the output at this location, if in bounds.
Sourcefn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>
fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>
Returns a mutable poiner to the output at this location, if in bounds.
Sourceunsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output
unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output
Returns a shared pointer to the output at this location, without
performing any bounds checking.
Calling this method with an out-of-bounds index or a dangling slice
pointer
is undefined behavior even if the resulting reference is not used.
Sourceunsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output
unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output
Returns a mutable pointer to the output at this location, without
performing any bounds checking.
Calling this method with an out-of-bounds index or a dangling slice
pointer
is undefined behavior even if the resulting reference is not used.