An idiomatic and fast QP-trie implementation in pure Rust.
```rust fn main() { use qp_trie::Trie; let mut trie = Trie::new(); for i in 0u8..3 { for j in 0u8..3 { trie.insert([i, j], i + j); } } for i in 0u8..3 { trie.remove([1, i]); } assert!(trie.iter().all(|(&key, _)| key[0] != 1)); } ``` ``` error[E0308]: mismatched types --> src/main.rs:13:21 | 8 | trie.insert([i, j], i + j); | ------ ----- this is of type `u8`, which causes `trie` to be inferred as `Trie<[u8; 2], u8>` | | | this is of type `[u8; 2]`, which causes `trie` to be inferred as `Trie<[u8; 2], u8>` ... 13 | trie.remove([1, i]); | ------ ^^^^^^ | | | | | expected `&_`, found `[u8; 2]` | | help: consider borrowing here: `&[1, i]` | arguments to this method are incorrect | = note: expected reference `&_` found array `[u8; 2]` note: method defined here --> /Users/chance/.cargo/registry/src/github.com-1ecc6299db9ec823/qp-trie-0.8.1/src/trie.rs:316:12 | 316 | pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> | ^^^^^^ For more information about this error, try `rustc --explain E0308`. ``` this one is fixed by referencing `[1, i]`: ```diff - trie.remove_prefix([1]); + trie.remove_prefix(&[1]); ``` ```rust fn main() { use qp_trie::Trie; let mut trie = Trie::new(); for i in 0u8..3 { trie.extend((0u8..3).map(|j| ([i, j], i + j))); } trie.remove_prefix([1]); assert!(trie.iter().all(|(&key, _)| key[0] != 1)); } ``` ``` error[E0308]: mismatched types --> src/main.rs:10:24 | 7 | trie.extend((0u8..3).map(|j| ([i, j], i + j))); | ------ here the type of `trie` is inferred to be `Trie<[u8; 2], u8>` ... 10 | trie.remove_prefix([1]); | ------------- ^^^ | | | | | expected `&_`, found `[{integer}; 1]` | | help: consider borrowing here: `&[1]` | arguments to this method are incorrect | = note: expected reference `&_` found array `[{integer}; 1]` note: method defined here --> /Users/chance/.cargo/registry/src/github.com-1ecc6299db9ec823/qp-trie-0.8.1/src/trie.rs:330:12 | 330 | pub fn remove_prefix<Q: ?Sized>(&mut self, prefix: &Q) -> Trie<K, V> | ^^^^^^^^^^^^^ For more information about this error, try `rustc --explain E0308`. ``` ```rust fn main() { use qp_trie::Trie; let mut trie = Trie::new(); for i in 0u8..3 { trie.extend((0u8..3).map(|k| ([i, j], i + j))); } let mut iter = trie.iter_prefix([1]); assert_eq!(iter.next(), Some((&[1, 0], &1))); assert_eq!(iter.next(), Some((&[1, 1], &2))); assert_eq!(iter.next(), Some((&[1, 2], &3))); assert_eq!(iter.next(), None); } ``` ``` error[E0425]: cannot find value `j` in this scope --> src/main.rs:7:43 | 7 | trie.extend((0u8..3).map(|k| ([i, j], i + j))); | ^ help: a local variable with a similar name exists: `i` error[E0425]: cannot find value `j` in this scope --> src/main.rs:7:51 | 7 | trie.extend((0u8..3).map(|k| ([i, j], i + j))); | ^ help: a local variable with a similar name exists: `i` error[E0308]: mismatched types --> src/main.rs:10:37 | 10 | let mut iter = trie.iter_prefix([1]); | ----------- ^^^ | | | | | expected `&_`, found `[{integer}; 1]` | | help: consider borrowing here: `&[1]` | arguments to this method are incorrect | = note: expected reference `&_` found array `[{integer}; 1]` note: method defined here --> /Users/chance/.cargo/registry/src/github.com-1ecc6299db9ec823/qp-trie-0.8.1/src/trie.rs:190:12 | 190 | pub fn iter_prefix<'a, Q: ?Sized>(&'a self, prefix: &Q) -> Iter<'a, K, V> | ^^^^^^^^^^^ Some errors have detailed explanations: E0308, E0425. For more information about an error, try `rustc --explain E0308`. ````
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be still under discussion. The issue was opened by chanced and has received 0 comments.