Trait Array

Source
pub trait Array<T> {
    // Required methods
    fn get(&self, idx: usize) -> Option<&T>;
    fn len() -> usize;

    // Provided methods
    unsafe fn as_slice(&self) -> &[T] { ... }
    fn size(&self) -> usize { ... }
}
Expand description

A generic trait for arbitarily fixed size arrays.

Required Methods§

Source

fn get(&self, idx: usize) -> Option<&T>

Access the element at idx, or None if out of bounds.

Source

fn len() -> usize

Get the compile-time length of the array.

Provided Methods§

Source

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.

Source

fn size(&self) -> usize

A conveinence wrapper around len that takes a refernce to facilitate using the right type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> Array<T> for Term

Source§

impl<T, L: Array<T>> Array<T> for Cons<T, L>