Struct symtern::Pool [] [src]

pub struct Pool<T: ?Sized, I = usize> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash,
    I: SymbolId
{ /* fields omitted */ }

Simple hash-based interner generic over both the type of interned values and the type used to represent symbol IDs.

Pool can intern any type that implements ToOwned, Eq, and Hash, where its owned type (ToOwned::Owned) also implements Eq and Hash.

use symtern::prelude::*;
use symtern::Pool;

#[derive(Clone, Eq, PartialEq, Hash)]
struct WibbleWobble {
    whee: Vec<u32>
}

let mut pool = Pool::<_,u8>::new();
assert!(pool.intern(&WibbleWobble{whee: vec![1, 2, 3, 4, 5]}).is_ok());

Methods

impl<T: ?Sized, I> Pool<T, I> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash,
    I: SymbolId
[src]

Create a new, empty Pool instance.

Trait Implementations

impl<T: Debug + ?Sized, I: Debug> Debug for Pool<T, I> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash,
    I: SymbolId,
    T::Owned: Debug
[src]

Formats the value using the given formatter.

impl<T: ?Sized, I> Clone for Pool<T, I> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash + Clone,
    I: SymbolId
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'a, T: ?Sized, I> Len for Pool<T, I> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash,
    I: SymbolId
[src]

Get the number of entries contained in the pool.

Check if the pool is "empty", i.e. has zero stored values.

Check if the number of interned symbols has reached the maximum allowed for the pool's ID type.

impl<T: ?Sized, I> Default for Pool<T, I> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash,
    I: SymbolId
[src]

Returns the "default value" for a type. Read more

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>, 
[src]

Type of value accepted by intern.

Type used to represent interned values.

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. Read more

impl<'a, T: ?Sized, I> Resolve for &'a Pool<T, I> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash + Borrow<T>,
    I: SymbolId
[src]

Type passed to the resolve method.

Type stored by the interner and made available with resolve.

Look up and return a reference to the value represented by a symbol, or an error if the symbol was not found. Read more

impl<'a, T: ?Sized, I> ResolveUnchecked for &'a Pool<T, I> where
    T: ToOwned + Eq + Hash,
    T::Owned: Eq + Hash + Borrow<T>,
    I: SymbolId
[src]

Resolve the given symbol into its referent, bypassing any validity checks. Read more