Array-backed ordered set and map data structures in Rust, optimized for stack-allocated storage of a tiny number of elements with a fixed cap.
Your elements only need Eq
, and this crate isno_std
compatible!
This crate is designed to be used in performance-sensitive contexts with a small number of elements, where iteration is more common than look-ups and you don't mind a fixed size. One particularly useful quirk is that elements are not recompacted upon removal: this can be very useful when replacing elements in a set or using the indexes that the elements are stored at in a semantic fashion. Iteration order is guaranteed to be stable, on a first-in-first-out basis.
If this isn't what you're after, check out one of these alternatives!
HashSet
when the number of elements is too large. Unordered.Hash
, unbounded size.Ord
, unbounded size.Hash
, unbounded size.This crate has a reasonable collection of convenience methods for working with both sets and maps, aiming for rough equivalence with HashMap
and HashSet
.
If you'd like more, please submit an issue or PR!
This repository is open to community contributions! Leafwing Studios attempts to adhere to the Rust API Guidelines. If you haven't seen it before, it's an excellent resource!
There are a few options if you'd like to help:
Any contributions made are provided under the license(s) listed in this repo at the time of their contribution, and do not require separate attribution.
#
to hide a setup line from the doc tests.#[cfg(test)]
on the test module to ignore it during builds, and #[test]
on the test functions to ensure they are run.tests
folder, importing functions from lib.rs
.Use cargo test
to run all tests.
The CI will:
cargo fmt
.clippy
lints pass.Check this locally with:
cargo run -p ci
cargo test --workspace
To manually rerun CI:
Actions
tab.Reference documentation is handled with standard Rust doc strings.
Use cargo doc --open
to build and then open the docs.
Design docs (or other book-format documentation) is handled with mdBook.
Install it with cargo install mdbook
, then use mdbook serve --open
to launch the docs.