pub trait AsRawSlice<T> {
    // Required methods
    fn ptr(&self) -> *const T;
    fn length(&self) -> usize;
    fn raw_slice(&self, begin: usize, len: usize) -> RawSlice<T>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn first_and_last_ptrs(&self) -> [*const T; 2] { ... }
    unsafe fn ptr_at(&self, position: usize) -> *const T { ... }
}
Expand description

A type that can be represented as a slice.

Required Methods§

Source

fn ptr(&self) -> *const T

Beginning of the slice.

Source

fn length(&self) -> usize

Length of the slice.

Source

fn raw_slice(&self, begin: usize, len: usize) -> RawSlice<T>

Creates a slice from this slice with len elements starting from the begin.

Provided Methods§

Source

fn is_empty(&self) -> bool

True if length is zero; false otherwise.

Source

fn first_and_last_ptrs(&self) -> [*const T; 2]

Returns pointers to the first and last, (len-1)-th, element of the slice.

If the slice is empty, both pointers are null.

Source

unsafe fn ptr_at(&self, position: usize) -> *const T

Returns the pointer to the position-th element of the slice.

§SAFETY

Must ensure that position is in bounds; otherwise, the method accesses out of bounds memory if position >= self.len().

Implementations on Foreign Types§

Source§

impl<T> AsRawSlice<T> for &[T]

Source§

fn ptr(&self) -> *const T

Source§

fn length(&self) -> usize

Source§

fn raw_slice(&self, begin: usize, len: usize) -> RawSlice<T>

Source§

impl<T> AsRawSlice<T> for Vec<T>

Source§

fn ptr(&self) -> *const T

Source§

fn length(&self) -> usize

Source§

fn raw_slice(&self, begin: usize, len: usize) -> RawSlice<T>

Implementors§

Source§

impl<T> AsRawSlice<T> for RawSlice<T>

Source§

impl<T> AsRawSlice<T> for RawVec<T>