| Crates.io | rstrie |
| lib.rs | rstrie |
| version | 0.6.0 |
| created_at | 2025-05-31 20:31:19.504146+00 |
| updated_at | 2025-06-04 03:08:10.74685+00 |
| description | A generalized Trie implementation for Rust. |
| homepage | https://github.com/DiscordJim/rstrie |
| repository | |
| max_upload_size | |
| id | 1696624 |
| size | 1,686,171 |
A generalized Trie implementation for Rust. The implementation supports generic tries, the only requirement is that the key 'fragments,' or the pieces that compose the key, be able to iterated from a key and collected into a key. The library has no external dependencies when not in development mode. In development mode there are several dependencies for benchmarking and the like.
Add the following line to your dependencies,
[dependencies]
rstrie = "0.5.0"
The following code demonstrates a simple Trie:
use rstrie::Trie;
let mut trie: Trie<char, usize> = Trie::new();
trie.insert("hello".chars(), 4);
trie.insert("hey".chars(), 5);
assert_eq!(trie.get("hello".chars()), Some(&4));
assert_eq!(trie.get("hey".chars()), Some(&5));
Trie that works with any data type.HashMapserde, rkyv)cargo fuzz run ops fuzz/artifacts/ops/crash-c7261ee3e185eb226e890252921a51f5f4ebaaf3
$ cargo install cargo-fuzz
$ rustup default nightly
$ cargo fuzz run fuzz_target_1
There are several examples contained within the examples folder.
examples/basic.rs has a basic String trie.examples/word_trie.rs features a word trie that composes into sentences.examples/bitrouting.rs features an IP routing table.examples/1984_trie.rs features a trie that ingests the contents of George Orwell's 1984.To run the benchmarks, you simply run the following command:
$ cargo bench