Debian Codegraph @

debian/rust-vendor/zerotrie/README.md

raw
1 # zerotrie [![crates.io](https://img.shields.io/crates/v/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 ## Safe Rust
14
15 All runtime lookup code in this crate is 100% safe Rust.
16
17 A small amount of unsafe Rust is used in these situations:
18
19 - Constructing unsized transparent newtypes (i.e. <https://github.com/rust-lang/rust/issues/18806>),
20 which is reachable from builder code and when creating a `&TypedZeroTrie<[u8]>` DST.
21 - Implementing unsafe traits when the `zerovec` feature is enabled
22
23 ## Examples
24
25 ```rust
26 use zerotrie::ZeroTrie;
27
28 let data: &[(&str, usize)] = &[("abc", 11), ("xyz", 22), ("axyb", 33)];
29
30 let trie: ZeroTrie<Vec<u8>> = data.iter().copied().collect();
31
32 assert_eq!(trie.get("axyb"), Some(33));
33 assert_eq!(trie.byte_len(), 18);
34 ```
35
36 ## Internal Structure
37
38 To read about the internal structure of [`ZeroTrie`], build the docs with private modules:
39
40 ```bash
41 cargo doc --document-private-items --all-features --no-deps --open
42 ```
43
44 [`LiteMap`]: litemap::LiteMap
45 [`BTreeMap`]: alloc::collections::BTreeMap
46
47 <!-- cargo-rdme end -->
48
49 ## More Information
50
51 For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).