The Flexible Table
for Rust
One fast, dynamic table for arrays, dictionaries, records and sets.
cargo add flextableOne structure
Sequences and fields, side by side
A table keeps integer keys in an array and everything else in an insertion-ordered hash part. You never choose between a Vec and a HashMap: write fields, push items, nest tables, and read them back in a predictable order.
src/main.rs
use flextable::{table, Table, Value};
let player = Table::new();
player.set("name", "Ada")?; // named fields
player.set("level", 7)?;
player.push("sword")?; // and a sequence
player.push("shield")?;
assert_eq!(player.len(), 2);
assert_eq!(player.field_count(), 4);
assert_eq!(player.get("name"), Value::from("Ada"));
let scores = table![42, 7, 19];
scores.sort()?;
assert_eq!(scores.concat(", ")?, "7, 19, 42");Features
What's in flextable?
One type, many shapesUse the same Table as a list, a dictionary, a record or a set, or all of them at once.Sequence librarypush, pop, insert, remove, concat, sort and move ranges, with 1-based positions.Iteration that bendspairs and ipairs tolerate changes mid-loop, next is O(1), and borrowing iterators never clone.Shared and nestableTables are cheap handles. Nest them, share them, and copy shallowly or deeply, cycles included.Built for speedO(1) length, an array part for integer keys, an ordered hash part, and lookups that never allocate.No surprisesTyped errors instead of panics, and a traversal order you can rely on.
1.1 nsto overwrite a sequence slot
O(1)length, append and lookup
58doc examples compiled and run
Start building with tables
Install the crate and write your first table in about five minutes.