Module varlen::seq

source · []
Expand description

A sequence of variable-length objects in a flat buffer.

For example, the Seq<Str<u8>> representation of ["hello", "good", "world!"] is:

Unlike Vec<T>, once an element has been pushed onto the sequence, its size cannot change. Also unlike Vec<T> there is no random access to the nth element of the sequence; access is primarily sequential although some indexing options exist. (TODO: explain)

Examples

Like Vec<T>, this type is a sequence of objects supporting amortized-O(1) push(), and you can iterate through elements of the sequence:

use varlen::prelude::*;
let mut seq: Seq<Str> = Seq::new();
seq.push(Str::copy("hello"));
seq.push(Str::copy("good"));
seq.push(Str::copy("world!"));
let v: Vec<&str> = seq.iter().map(|s| &s[..]).collect();
assert_eq!(vec!["hello", "good", "world!"], v);

Module contents

The main type is Seq<T>. It includes iterator types Iter<T>, IterMut<T> and OwnedElems<T>.

Types CheckedIndexing and UncheckedIndexing parametrize the Seq<T> and control whether checked random access is available.

Macros

Creates a sequence with the specified elements.

Structs

Checked indexing strategy for sequences.

Iterates over references.

Iterate over mutable (pinned) references.

Iterate over Owned<T> values.

A sequence of variable-length objects in a flat buffer.

Unchecked indexing strategy for sequences.

Traits

Controls what kind of indexing is available on a sequence: either CheckedIndexing or UncheckedIndexing.

Type Definitions

A sequence with safe indexing by integers.