icu_codepointtrie_builder
is a utility crate of the [ICU4X
] project.
This crate exposes functionality to build a [CodePointTrie
] from values provided at runtime.
Because it is normally expected for CodePointTrie data to be pre-compiled, this crate is not
optimized for speed; it should be used during a build phase.
Under the hood, this crate uses the CodePointTrie builder code from ICU4C, [UMutableCPTrie
],
shipped as a WebAssembly module and then JIT-compiled at runtime. For more context, see
https://github.com/unicode-org/icu4x/issues/1837.
```rust use icucollections::codepointtrie::CodePointTrie; use icucollections::codepointtrie::TrieType; use icucodepointtriebuilder::CodePointTrieBuilder; use icucodepointtriebuilder::CodePointTrieBuilderData;
let defaultvalue = 1; let errorvalue = 2; let valuesbycode_point = &[3, 4, 5, 6];
let cpt: CodePointTrie
asserteq!(cpt.get(0), 3); asserteq!(cpt.get(1), 4); asserteq!(cpt.get(2), 5); asserteq!(cpt.get(3), 6); asserteq!(cpt.get(4), 1); // default value asserteq!(cpt.get(u32::MAX), 2); // error value ```
For more information on development, authorship, contributing etc. please visit ICU4X home page
.