Interner

Struct Interner 

Source
pub struct Interner<T> { /* private fields */ }

Implementations§

Source§

impl<T> Interner<T>

Source

pub const fn new() -> Self

Creates an empty Interner. The current implementation does not allocate

Source

pub fn len(&self) -> usize

Returns the number of entries in the interner

Source

pub fn is_empty(&self) -> bool

Returns true if the interner contains no elements

Source

pub fn insert_arena(&self, value: T) -> &mut T

Source§

impl<T: Hash + Eq> Interner<T>

Source

pub fn try_resolve<Q>(&self, value: &Q) -> Option<&T>
where T: Borrow<Q>, Q: ?Sized + Hash + Eq,

Will return a reference to an equivalent value if it already exists

Source

pub fn intern(&self, value: T) -> &T

Returns a reference to either the value provided, or an equivalent value that was already inserted

Source

pub fn intern_new(&self, value: T) -> &T

Inserts the value into the interner without checking if the value already exists

Source

pub fn intern_ref_unique(&self, value: &'static T)

Inserts a reference to the value into the interner. All future calls the Interner::intern will return the provided reference.

This function will not check if an equivalent value already exists within the table, and may behave weirdly if one does.

Trait Implementations§

Source§

impl<T: Debug> Debug for Interner<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Interner<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: Send> Send for Interner<T>

Source§

impl<T: Sync> Sync for Interner<T>

Auto Trait Implementations§

§

impl<T> !Freeze for Interner<T>

§

impl<T> RefUnwindSafe for Interner<T>

§

impl<T> Unpin for Interner<T>
where T: Unpin,

§

impl<T> UnwindSafe for Interner<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.