Trait deferred_reference::SlicePointerIndex[][src]

pub unsafe trait SlicePointerIndex<T: ?Sized> where
    T: SliceLike
{ type Output: ?Sized; 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; }

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).

Associated Types

type Output: ?Sized[src]

The output type returned by methods.

Loading content...

Required methods

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

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

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

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

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

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.

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

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.

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

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

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

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

Loading content...

Implementations on Foreign Types

impl<T: ?Sized> SlicePointerIndex<T> for Range<usize> where
    T: SliceLike
[src]

type Output = [T::Element]

impl<T: ?Sized> SlicePointerIndex<T> for RangeTo<usize> where
    T: SliceLike
[src]

type Output = [T::Element]

impl<T: ?Sized> SlicePointerIndex<T> for RangeFrom<usize> where
    T: SliceLike
[src]

type Output = [T::Element]

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

type Output = [T]

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

type Output = [T]

impl<T: ?Sized> SlicePointerIndex<T> for RangeInclusive<usize> where
    T: SliceLike
[src]

type Output = [T::Element]

impl<T: ?Sized> SlicePointerIndex<T> for RangeToInclusive<usize> where
    T: SliceLike
[src]

type Output = [T::Element]

Loading content...

Implementors

impl<T: ?Sized> SlicePointerIndex<T> for usize where
    T: SliceLike
[src]

type Output = T::Element

Loading content...