pub struct Fastrie<'v, 'd, V> { /* private fields */ }
Implementations
sourceimpl<V> Fastrie<'_, '_, V>
impl<V> Fastrie<'_, '_, V>
sourcepub const fn from_prebuilt<'v, 'd>(
values: &'v [V],
data: &'d [u8]
) -> Fastrie<'v, 'd, V>
pub const fn from_prebuilt<'v, 'd>(
values: &'v [V],
data: &'d [u8]
) -> Fastrie<'v, 'd, V>
Example
use fastrie::*;
let mut builder = FastrieBuilderNode::new();
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.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);
pub fn memory_size(&self) -> usize
pub fn contains_key(&self, key: &[u8]) -> bool
pub fn longest_matching_prefix(&self, text: &[u8]) -> Option<FastrieMatch<'_, V>>
Auto Trait Implementations
impl<'v, 'd, V> RefUnwindSafe for Fastrie<'v, 'd, V>where
V: RefUnwindSafe,
impl<'v, 'd, V> Send for Fastrie<'v, 'd, V>where
V: Sync,
impl<'v, 'd, V> Sync for Fastrie<'v, 'd, V>where
V: Sync,
impl<'v, 'd, V> Unpin for Fastrie<'v, 'd, V>
impl<'v, 'd, V> UnwindSafe for Fastrie<'v, 'd, V>where
V: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more