Trait linked_array::Array
[−]
[src]
pub trait Array<T> { fn get(&self, idx: usize) -> Option<&T>; fn len() -> usize; unsafe fn as_slice(&self) -> &[T] { ... } fn size(&self) -> usize { ... } }
A generic trait for arbitarily fixed size arrays.
Required Methods
fn get(&self, idx: usize) -> Option<&T>
Access the element at idx, or None if out of bounds.
fn len() -> usize
Get the compile-time length of the array.
Provided Methods
unsafe fn as_slice(&self) -> &[T]
Since the in-memory representation should be the same as a traditional array, it should be safe to read the pointer as one. However, since the rust specification makes memory layout undefined, it is held behind unsafe.
fn size(&self) -> usize
A conveinence wrapper around len that takes a refernce to facilitate using the right type.