Skip to main content

NameMapIntern

Trait NameMapIntern 

Source
pub trait NameMapIntern {
    type Key: Borrow<Self::BorrowedKey>;
    type BorrowedKey: ?Sized + TryToOwned<Owned = Self::Key>;

    // Required methods
    fn intern(&mut self, s: &str) -> Result<Self::Key, OutOfMemory>;
    fn lookup<'a>(&'a self, s: &'a str) -> Option<TryCow<'a, Self::BorrowedKey>>;
}
Expand description

A helper trait used in conjunction with NameMap to optionally intern keys to non-strings.

Required Associated Types§

Source

type Key: Borrow<Self::BorrowedKey>

The key that this interning context generates.

Source

type BorrowedKey: ?Sized + TryToOwned<Owned = Self::Key>

The borrowed version of the key type.

Required Methods§

Source

fn intern(&mut self, s: &str) -> Result<Self::Key, OutOfMemory>

Inserts s into self and returns the intern’d key Self::Key.

Source

fn lookup<'a>(&'a self, s: &'a str) -> Option<TryCow<'a, Self::BorrowedKey>>

Looks up s in self returning Some if it was found or None if it’s not present.

Implementors§