Trait symtern::traits::Intern
[−]
[src]
pub trait Intern { type Input: ?Sized; type Symbol: Symbol + Symbol; fn intern(self, value: &Self::Input) -> Result<Self::Symbol>; }
Primary interface for interner implementations. For a given type T
, this
type should implemented for &'a T
or &'a mut T
.
Associated Types
type Input: ?Sized
Type of value accepted by intern
.
type Symbol: Symbol + Symbol
Type used to represent interned values.
Required Methods
fn intern(self, value: &Self::Input) -> Result<Self::Symbol>
Fetch the symbol that corresponds to the given value. If the value does not map to any existing symbol, create and return a new one. This method may return an error if the interner encounters any error while storing the value.
let symbol = match some_interner.intern("Rosebud") { Ok(sym) => sym, Err(err) => return Err(MyErrorType::from(err)), };
Implementors
impl<'a, T: ?Sized, I> Intern for &'a mut Pool<T, I> where I: SymbolId, T: ToOwned + Eq + Hash, T::Owned: Eq + Hash + Borrow<T>
impl<'a, W, WS> Intern for &'a Inline<W> where W: Len + Pool<Symbol=WS>, &'a W: Intern<Input=str, Symbol=W::Symbol>, WS: Symbol, WS::Id: Pack
impl<'a, W, WS> Intern for &'a mut Inline<W> where W: Len + Pool<Symbol=WS>, &'a mut W: Intern<Input=str, Symbol=W::Symbol>, WS: Symbol, WS::Id: Pack
impl<'a, W, BS, BI: ?Sized> Intern for &'a Luma<W> where &'b mut W: Intern<Symbol=BS, Input=BI>, BS: Symbol + Symbol