Struct c_vec::CSlice [] [src]

pub struct CSlice<T> {
    // some fields omitted
}

The type representing an 'unsafe' foreign chunk of memory

Methods

impl<T> CSlice<T>

unsafe fn new(base: *mut T, len: usize) -> CSlice<T>

Create a CSlice from a raw pointer to a buffer with a given length.

Panics if the given pointer is null. The returned vector will not attempt to deallocate the vector when dropped.

Arguments

  • base - A raw pointer to a buffer
  • len - The number of elements in the buffer

fn get<'a>(&'a self, ofs: usize) -> Option<&'a T>

Retrieves an element at a given index, returning None if the requested index is greater than the length of the vector.

fn get_mut<'a>(&'a mut self, ofs: usize) -> Option<&'a mut T>

Retrieves a mutable element at a given index, returning None if the requested index is greater than the length of the vector.

fn len(&self) -> usize

Returns the number of items in this vector.

fn is_empty(&self) -> bool

Returns whether this vector is empty.

Trait Implementations

impl<T> AsRef<[T]> for CSlice<T>

fn as_ref(&self) -> &[T]

impl<T> AsMut<[T]> for CSlice<T>

fn as_mut(&mut self) -> &mut [T]

impl<T> Index<usize> for CSlice<T>

type Output = T

fn index<'a>(&'a self, _index: usize) -> &'a T

impl<T> IndexMut<usize> for CSlice<T>

fn index_mut<'a>(&'a mut self, _index: usize) -> &'a mut T