pub struct Interner<K = NonZeroU32, S = RandomState> { /* private fields */ }
Expand description

String interner.

See the module documentation for information about this data structure.

Implementations§

source§

impl<K: Key, S: BuildHasher> Interner<K, S>

source

pub fn get_or_intern(&mut self, s: &str) -> K

Intern the provided string and return its key.

source

pub fn get(&self, s: &str) -> Option<K>

Get the key for the provided string if it has been already been interned.

This method is useful when the caller only has a shared reference to the interner.

source

pub fn resolve(&self, k: K) -> Option<&str>

Return the interned string corresponding to the provided key.

Trait Implementations§

source§

impl<K, S: Default> Default for Interner<K, S>

source§

fn default() -> Self

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

impl<'de, K: Key, S: Default + BuildHasher> Deserialize<'de> for Interner<K, S>

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<K, S> Serialize for Interner<K, S>

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<K, S> RefUnwindSafe for Interner<K, S>where K: RefUnwindSafe, S: RefUnwindSafe,

§

impl<K, S> Send for Interner<K, S>where K: Send, S: Send,

§

impl<K, S> Sync for Interner<K, S>where K: Sync, S: Sync,

§

impl<K, S> Unpin for Interner<K, S>where K: Unpin, S: Unpin,

§

impl<K, S> UnwindSafe for Interner<K, S>where K: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,