Crates.io | trying |
lib.rs | trying |
version | 0.5.1 |
source | src |
created_at | 2021-10-22 14:44:48.466472 |
updated_at | 2023-07-29 08:20:29.827982 |
description | Basic trie crate |
homepage | |
repository | https://github.com/garypen/trying |
max_upload_size | |
id | 469390 |
size | 677,022 |
Provides a simple Trie implementation for storing "keys" composed of "atoms".
The trie imposes restrictions on the key, atom and value types:
(where A represents the Atom type that the key will be represented as)
With these restrictions in place, the trie implements a reasonably efficient mechanism for:
For Example:
use trying::trie::TrieVec;
use unicode_segmentation::UnicodeSegmentation;
// Declare a trie which will store &str keys
// with usize values.
let mut trie = TrieVec::<&str, usize>::new();
let s = "a̐éö̲\r\n";
let input = s.graphemes(true);
// Insert our graphemes into the trie
trie.insert(input.clone());
// Anything which implements IntoIterator<Item=&str> can now be used
// to interact with our Trie
assert!(trie.contains(input.clone()));
assert!(trie.remove(input.clone()).is_none());
assert!(!trie.contains(input));
If you don't need prefix matching, then a HashMap is almost always a better choice than a trie...
[dependencies]
trying = "0.5"
Apache 2.0 licensed. See LICENSE for details.