Struct fastrie::Fastrie

source ·
pub struct Fastrie<'v, 'd, V> { /* private fields */ }

Implementations

Example
use fastrie::*;

let mut builder = FastrieBuilderNode::new(IndexWidth(3));
builder.add(b"hell", 1);
builder.add(b"hello", 2);
builder.add(b"world", 4);
let build = builder.prebuild();

// `build.data` can be written as bytes to a file, or embedded directly into code as a literal byte array/slice.

let trie = Fastrie::from_prebuilt(build.index_width, &build.values, &build.data);
assert!(trie.contains_key(b"hello"));
let query = b"hello world!";
let mat = trie.longest_matching_prefix(query).unwrap();
assert_eq!(mat.end, 4);
assert_eq!(&query[..=mat.end], b"hello");
assert_eq!(mat.value, &2);
let query = b"hell's kitchen";
let mat = trie.longest_matching_prefix(query).unwrap();
assert_eq!(mat.end, 3);
assert_eq!(&query[..=mat.end], b"hell");
assert_eq!(mat.value, &1);

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.