Trait lasso::Interner

source ·
pub trait Interner<K = Spur>: Reader<K> + Resolver<K> {
    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§

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)

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

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)

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§

Implementors§