Struct tetsy_scale_info::interner::Interner[][src]

pub struct Interner<T> { /* fields omitted */ }

Interning data structure generic over the element type.

For the sake of simplicity and correctness we are using a rather naive implementation.

Usage

This is used in order to quite efficiently cache strings and type definitions uniquely identified by their associated type identifiers.

Implementations

impl<T> Interner<T> where
    T: Ord
[src]

pub fn new() -> Self[src]

Creates a new empty interner.

impl<T> Interner<T> where
    T: Ord + Clone
[src]

pub fn intern_or_get(&mut self, s: T) -> (bool, Symbol<'_, T>)[src]

Interns the given element or returns its associated symbol if it has already been interned.

pub fn get(&self, s: &T) -> Option<Symbol<'_, T>>[src]

Returns the symbol of the given element or None if it hasn't been interned already.

pub fn resolve(&self, sym: Symbol<'_, T>) -> Option<&T>[src]

Resolves the original element given its associated symbol or returns None if it has not been interned yet.

Trait Implementations

impl<T: Debug> Debug for Interner<T>[src]

impl<T: Ord> Default for Interner<T>[src]

impl<T: Eq> Eq for Interner<T>[src]

impl<T: PartialEq> PartialEq<Interner<T>> for Interner<T>[src]

impl<T> StructuralEq for Interner<T>[src]

impl<T> StructuralPartialEq for Interner<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Interner<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Interner<T> where
    T: Send
[src]

impl<T> Sync for Interner<T> where
    T: Sync
[src]

impl<T> Unpin for Interner<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Interner<T> where
    T: RefUnwindSafe + UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.