| 1 | # zerotrie [](https://crates.io/crates/zerotrie) |
| 2 | |
| 3 | <!-- cargo-rdme start --> |
| 4 | |
| 5 | A data structure offering zero-copy storage and retrieval of byte strings, with a focus |
| 6 | on the efficient storage of ASCII strings. Strings are mapped to `usize` values. |
| 7 | |
| 8 | [`ZeroTrie`] does not support mutation because doing so would require recomputing the entire |
| 9 | data structure. Instead, it supports conversion to and from [`LiteMap`] and [`BTreeMap`]. |
| 10 | |
| 11 | There are multiple variants of [`ZeroTrie`] optimized for different use cases. |
| 12 | |
| 13 | ## Examples |
| 14 | |
| 15 | ```rust |
| 16 | use zerotrie::ZeroTrie; |
| 17 | |
| 18 | let data: &[(&str, usize)] = &[("abc", 11), ("xyz", 22), ("axyb", 33)]; |
| 19 | |
| 20 | let trie: ZeroTrie<Vec<u8>> = data.iter().copied().collect(); |
| 21 | |
| 22 | assert_eq!(trie.get("axyb"), Some(33)); |
| 23 | assert_eq!(trie.byte_len(), 18); |
| 24 | ``` |
| 25 | |
| 26 | ## Internal Structure |
| 27 | |
| 28 | To read about the internal structure of [`ZeroTrie`], build the docs with private modules: |
| 29 | |
| 30 | ```bash |
| 31 | cargo doc --document-private-items --all-features --no-deps --open |
| 32 | ``` |
| 33 | |
| 34 | [`LiteMap`]: litemap::LiteMap |
| 35 | [`BTreeMap`]: alloc::collections::BTreeMap |
| 36 | |
| 37 | <!-- cargo-rdme end --> |
| 38 | |
| 39 | ## More Information |
| 40 | |
| 41 | For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x). |