Trait lasso::Interner

source ·
pub trait Interner<K = Spur>: Reader<K> + Resolver<K> {
    // Required methods
    fn get_or_intern(&mut self, val: &str) -> K;
    fn try_get_or_intern(&mut self, val: &str) -> LassoResult<K>;
    fn get_or_intern_static(&mut self, val: &'static str) -> K;
    fn try_get_or_intern_static(&mut self, val: &'static str) -> LassoResult<K>;
}
Expand description

A generic interface over any underlying interner, allowing storing and accessing interned strings

Note that because single-threaded Rodeos require mutable access to use, this trait does so as well. For use with ThreadedRodeo, the trait is implemented for &ThreadedRodeo as well to allow access through shared references.

Required Methods§

source

fn get_or_intern(&mut self, val: &str) -> K

Get the key for a string, interning it if it does not yet exist

Panics

Panics if the key’s try_from_usize function fails. With the default keys, this means that you’ve interned more strings than it can handle. (For Spur this means that u32::MAX - 1 unique strings were interned)

source

fn try_get_or_intern(&mut self, val: &str) -> LassoResult<K>

Get the key for a string, interning it if it does not yet exist

source

fn get_or_intern_static(&mut self, val: &'static str) -> K

Get the key for a static string, interning it if it does not yet exist

This will not reallocate or copy the given string

Panics

Panics if the key’s try_from_usize function fails. With the default keys, this means that you’ve interned more strings than it can handle. (For Spur this means that u32::MAX - 1 unique strings were interned)

source

fn try_get_or_intern_static(&mut self, val: &'static str) -> LassoResult<K>

Get the key for a static string, interning it if it does not yet exist

This will not reallocate or copy the given string

Implementations on Foreign Types§

source§

impl<T, K> Interner<K> for &mut Twhere T: Interner<K>,

source§

fn get_or_intern(&mut self, val: &str) -> K

source§

fn try_get_or_intern(&mut self, val: &str) -> LassoResult<K>

source§

fn get_or_intern_static(&mut self, val: &'static str) -> K

source§

fn try_get_or_intern_static(&mut self, val: &'static str) -> LassoResult<K>

source§

impl<K, I> Interner<K> for Box<I>where K: Key, I: Interner<K> + ?Sized + 'static,

source§

fn get_or_intern(&mut self, val: &str) -> K

source§

fn try_get_or_intern(&mut self, val: &str) -> LassoResult<K>

source§

fn get_or_intern_static(&mut self, val: &'static str) -> K

source§

fn try_get_or_intern_static(&mut self, val: &'static str) -> LassoResult<K>

Implementors§

source§

impl<K, S> Interner<K> for &ThreadedRodeo<K, S>where K: Key + Hash, S: BuildHasher + Clone,

source§

impl<K, S> Interner<K> for Rodeo<K, S>where K: Key, S: BuildHasher,

source§

impl<K, S> Interner<K> for ThreadedRodeo<K, S>where K: Key + Hash, S: BuildHasher + Clone,