nickel_lang_vector/lib.rs
1//! This crate provides persistent data structures tailored to Nickel's needs.
2//!
3//! [`Vector`] is a persistent vector (also known as a "bitmapped vector trie")
4//! with cheap clones and efficient copy-on-write modifications. [`Slice`]
5//! backs the implementation of arrays in Nickel. It's basically a [`Vector`]
6//! with support for slicing.
7
8// Not yet implemented (do we need them?)
9// - deletion
10// - mutable indexing
11
12pub mod slice;
13pub mod vector;
14
15/// [`Vector`] takes a "branching factor" parameter, which must be a
16/// reasonably-sized power of two. We use this trait to enforce that.
17pub trait ValidBranchingConstant {}
18pub struct Const<const N: usize> {}
19
20impl ValidBranchingConstant for Const<2> {}
21impl ValidBranchingConstant for Const<4> {}
22impl ValidBranchingConstant for Const<8> {}
23impl ValidBranchingConstant for Const<16> {}
24impl ValidBranchingConstant for Const<32> {}
25impl ValidBranchingConstant for Const<64> {}
26impl ValidBranchingConstant for Const<128> {}
27
28pub use slice::Slice;
29pub use vector::Vector;