Trait tinyvec::Array[][src]

pub trait Array {
    type Item: Default;

    const CAPACITY: usize;

    fn as_slice(&self) -> &[Self::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
;
fn as_slice_mut(&mut self) -> &mut [Self::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
;
fn default() -> Self; }

A trait for types that are an array.

An “array”, for our purposes, has the following properties:

  • Owns some number of elements.
  • The element type can be generic, but must implement Default.
  • The capacity is fixed at compile time, based on the implementing type.
  • You can get a shared or mutable slice to the elements.

You are generally not expected to need to implement this yourself. It is already implemented for all the major array lengths (0..=32 and the powers of 2 up to 4,096).

Additional lengths can easily be added upon request.

Safety Reminder

Just a reminder: this trait is 100% safe, which means that unsafe code must not rely on an instance of this trait being correct.

Associated Types

type Item: Default[src]

The type of the items in the thing.

Loading content...

Associated Constants

const CAPACITY: usize[src]

The number of slots in the thing.

Loading content...

Required methods

fn as_slice(&self) -> &[Self::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Gives a shared slice over the whole thing.

A correct implementation will return a slice with a length equal to the CAPACITY value.

fn as_slice_mut(&mut self) -> &mut [Self::Item]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Gives a unique slice over the whole thing.

A correct implementation will return a slice with a length equal to the CAPACITY value.

fn default() -> Self[src]

Create a default-initialized instance of ourself, similar to the Default trait, but implemented for the same range of sizes as Array.

Loading content...

Implementations on Foreign Types

impl<T: Default> Array for [T; 0][src]

type Item = T

impl<T: Default> Array for [T; 1][src]

type Item = T

impl<T: Default> Array for [T; 2][src]

type Item = T

impl<T: Default> Array for [T; 3][src]

type Item = T

impl<T: Default> Array for [T; 4][src]

type Item = T

impl<T: Default> Array for [T; 5][src]

type Item = T

impl<T: Default> Array for [T; 6][src]

type Item = T

impl<T: Default> Array for [T; 7][src]

type Item = T

impl<T: Default> Array for [T; 8][src]

type Item = T

impl<T: Default> Array for [T; 9][src]

type Item = T

impl<T: Default> Array for [T; 10][src]

type Item = T

impl<T: Default> Array for [T; 11][src]

type Item = T

impl<T: Default> Array for [T; 12][src]

type Item = T

impl<T: Default> Array for [T; 13][src]

type Item = T

impl<T: Default> Array for [T; 14][src]

type Item = T

impl<T: Default> Array for [T; 15][src]

type Item = T

impl<T: Default> Array for [T; 16][src]

type Item = T

impl<T: Default> Array for [T; 17][src]

type Item = T

impl<T: Default> Array for [T; 18][src]

type Item = T

impl<T: Default> Array for [T; 19][src]

type Item = T

impl<T: Default> Array for [T; 20][src]

type Item = T

impl<T: Default> Array for [T; 21][src]

type Item = T

impl<T: Default> Array for [T; 22][src]

type Item = T

impl<T: Default> Array for [T; 23][src]

type Item = T

impl<T: Default> Array for [T; 24][src]

type Item = T

impl<T: Default> Array for [T; 25][src]

type Item = T

impl<T: Default> Array for [T; 26][src]

type Item = T

impl<T: Default> Array for [T; 27][src]

type Item = T

impl<T: Default> Array for [T; 28][src]

type Item = T

impl<T: Default> Array for [T; 29][src]

type Item = T

impl<T: Default> Array for [T; 30][src]

type Item = T

impl<T: Default> Array for [T; 31][src]

type Item = T

impl<T: Default> Array for [T; 32][src]

type Item = T

impl<T: Default> Array for [T; 33][src]

type Item = T

impl<T: Default> Array for [T; 64][src]

type Item = T

impl<T: Default> Array for [T; 128][src]

type Item = T

impl<T: Default> Array for [T; 256][src]

type Item = T

impl<T: Default> Array for [T; 512][src]

type Item = T

impl<T: Default> Array for [T; 1024][src]

type Item = T

impl<T: Default> Array for [T; 2048][src]

type Item = T

impl<T: Default> Array for [T; 4096][src]

type Item = T

Loading content...

Implementors

Loading content...