Expand description

A variable-length array with inline storage.

This consists of an integer length field, followed immediately (subject to alignment) by the array payload of the specified length. For example, the VBox<Array<u8>> representation of [10u8, 11, 12] is:

Once allocated, the array size may not be modified.

Examples

use varlen::prelude::*;
use varlen::Layout;
let a = VBox::<Array<u8>>::new(Array::copy(&[1u8, 2, 3]));
assert_eq!(&a[..], &[1, 2, 3]);
// Layout is as specified above:
assert_eq!(a.calculate_layout().size(), std::mem::size_of::<usize>() + 3)

Module contents

The main type is Array<T>, valid length types for the array are ArrayLen, its memory layout is calculated and stored in ArrayLayout, and its general initializer is SizedInit.

Structs

An variable-length array with inline storage.

Initializer type for cloning an array.

The memory layout of an Array.

Initializer for an Array<T> given a specified length and array initializer.

Traits

Integer types that are valid lengths for Array<T>.