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>
[src]

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>
[src]

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

View the stored data as a slice.

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

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

View the stored data as a slice.

impl<T> Index<usize> for CSlice<T>
[src]

type Output = T

The returned type after indexing

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

The method for the indexing (Foo[Bar]) operation

impl<T> IndexMut<usize> for CSlice<T>
[src]

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

The method for the indexing (Foo[Bar]) operation