[][src]Macro arrav::ArravOf

macro_rules! ArravOf {
    ($container:ty as $t:ty) => { ... };
}

Produce an Arrav type that fits in a given container type.

Using ArravOf!, you can easily write out an Arrav type that can contain as many of one type as fit in the size of a different type. This is better explain with examples:

#![feature(const_panic, const_if_match)]
use arrav::{Arrav, ArravOf};
use std::mem::{size_of, size_of_val};

let v: ArravOf! {u64 as u8} = Arrav::new();
assert_eq!(size_of_val(&v), size_of::<u64>());
assert_eq!(v.capacity(), 64 / 8);

let v: ArravOf! {usize as u8} = Arrav::new();
assert_eq!(size_of_val(&v), size_of::<usize>());
assert_eq!(v.capacity(), size_of_val(&0usize) /* bytes */ * 8 / 8);
  • Create a Arrav from a given element and size:
let v = arrav::avec![1; 3];
assert_eq!(&*v, &[1, 1, 1]);