Skip to main content

SlicePointerIndex

Trait SlicePointerIndex 

Source
pub unsafe trait SlicePointerIndex<T>
where T: SliceLike + ?Sized,
{ 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§

Source

type Output: ?Sized

The output type returned by methods.

Required Methods§

Source

fn get(self, slice: *const T) -> Option<*const Self::Output>

Returns a shared pointer to the output at this location, if in bounds.

Source

fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>

Returns a mutable poiner to the output at this location, if in bounds.

Source

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.

Source

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.

Source

fn index(self, slice: *const T) -> *const Self::Output

Returns a shared pointer to the output at this location, panicking if out of bounds.

Source

fn index_mut(self, slice: *mut T) -> *mut Self::Output

Returns a mutable pointer to the output at this location, panicking if out of bounds.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, const N: usize> SlicePointerIndex<[T; N]> for RangeFull

Source§

impl<T> SlicePointerIndex<T> for Range<usize>
where T: SliceLike + ?Sized,

Source§

type Output = [<T as SliceLike>::Element]

Source§

fn get(self, slice: *const T) -> Option<*const Self::Output>

Source§

fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output

Source§

fn index(self, slice: *const T) -> *const Self::Output

Source§

fn index_mut(self, slice: *mut T) -> *mut Self::Output

Source§

impl<T> SlicePointerIndex<T> for RangeFrom<usize>
where T: SliceLike + ?Sized,

Source§

type Output = [<T as SliceLike>::Element]

Source§

fn get(self, slice: *const T) -> Option<*const Self::Output>

Source§

fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output

Source§

fn index(self, slice: *const T) -> *const Self::Output

Source§

fn index_mut(self, slice: *mut T) -> *mut Self::Output

Source§

impl<T> SlicePointerIndex<T> for RangeInclusive<usize>
where T: SliceLike + ?Sized,

Source§

type Output = [<T as SliceLike>::Element]

Source§

fn get(self, slice: *const T) -> Option<*const Self::Output>

Source§

fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output

Source§

fn index(self, slice: *const T) -> *const Self::Output

Source§

fn index_mut(self, slice: *mut T) -> *mut Self::Output

Source§

impl<T> SlicePointerIndex<T> for RangeTo<usize>
where T: SliceLike + ?Sized,

Source§

type Output = [<T as SliceLike>::Element]

Source§

fn get(self, slice: *const T) -> Option<*const Self::Output>

Source§

fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output

Source§

fn index(self, slice: *const T) -> *const Self::Output

Source§

fn index_mut(self, slice: *mut T) -> *mut Self::Output

Source§

impl<T> SlicePointerIndex<T> for RangeToInclusive<usize>
where T: SliceLike + ?Sized,

Source§

type Output = [<T as SliceLike>::Element]

Source§

fn get(self, slice: *const T) -> Option<*const Self::Output>

Source§

fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output

Source§

fn index(self, slice: *const T) -> *const Self::Output

Source§

fn index_mut(self, slice: *mut T) -> *mut Self::Output

Source§

impl<T> SlicePointerIndex<T> for usize
where T: SliceLike + ?Sized,

Source§

type Output = <T as SliceLike>::Element

Source§

fn get(self, slice: *const T) -> Option<*const Self::Output>

Source§

fn get_mut(self, slice: *mut T) -> Option<*mut Self::Output>

Source§

unsafe fn get_unchecked(self, slice: *const T) -> *const Self::Output

Source§

unsafe fn get_unchecked_mut(self, slice: *mut T) -> *mut Self::Output

Source§

fn index(self, slice: *const T) -> *const Self::Output

Source§

fn index_mut(self, slice: *mut T) -> *mut Self::Output

Source§

impl<T> SlicePointerIndex<[T]> for RangeFull

Implementors§