Skip to main content

PrefixMap

Trait PrefixMap 

Source
pub trait PrefixMap<V> {
    // Required method
    fn get_longest_prefix<P: AsRef<str>>(&self, inp: P) -> Option<(usize, &V)>;
}
Expand description

A PrefixMap is a map that supports operations on the prefix of an input

Required Methods§

Source

fn get_longest_prefix<P: AsRef<str>>(&self, inp: P) -> Option<(usize, &V)>

Get the corresponding length and value of the key that is part of the lonest prefix of inp

§Example
use asciimath_parser::prefix_map::{HashPrefixMap, PrefixMap};

let map = HashPrefixMap::from_iter([("a", 1), ("abc", 3)]);
assert_eq!(map.get_longest_prefix("ab"), Some((1, &1)));

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<K, V> PrefixMap<V> for QpTriePrefixMap<K, V>
where K: Borrow<str> + Clone,

Source§

impl<K, V, S> PrefixMap<V> for HashPrefixMap<K, V, S>
where K: Borrow<str> + Hash + Eq, S: BuildHasher,

Source§

impl<K: Borrow<str>, V> PrefixMap<V> for LinearPrefixMap<K, V>