| Crates.io | xtri |
| lib.rs | xtri |
| version | 0.1.1 |
| created_at | 2025-08-08 12:26:01.051853+00 |
| updated_at | 2025-08-08 12:29:55.005929+00 |
| description | A fast, memory-efficient radix tree (compressed trie) implementation in Rust with UTF-8 support |
| homepage | https://github.com/oramasearch/xtri |
| repository | https://github.com/oramasearch/xtri |
| max_upload_size | |
| id | 1786702 |
| size | 90,916 |
A Rust library that implements a radix tree (compressed trie) data structure for efficient string storage and prefix-based searching.
RadixTree<T> supporting any value typesearch_prefix and search_iter)mut_value)use xtri::{RadixTree, SearchMode};
fn main() {
let mut tree = RadixTree::new();
// Insert key-value pairs
tree.insert("application", "main app");
tree.insert("app", "short form");
tree.insert("apple", "fruit");
tree.insert("apply", "verb");
tree.insert("approach", "method");
tree.insert("appropriate", "suitable");
// Search by prefix - returns all keys starting with "app"
let iter = tree.search_iter("app", SearchMode::Prefix);
for (key, value) in iter {
println!(" {} -> {}", String::from_utf8_lossy(&key), value);
}
// Output:
// apple: fruit
// application: main app
// apply: verb
// Update existing value or create a new one
tree.mut_value("app", |value| {
*value = Some("short form");
});
let iter = tree.search_iter("app", SearchMode::Exact);
for (key, value) in iter {
println!(" {} -> {}", String::from_utf8_lossy(&key), value);
}
// Output:
// app -> short form
}