Trait lasso::Interner[][src]

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

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

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)

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

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

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

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)

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

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

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

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

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

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

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

Implementors

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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