Struct PackedInterner

Source
pub struct PackedInterner<Key = u32, Idx = usize, H = BuildHasherDefault<FxHasher>> { /* private fields */ }
Expand description

Interner that checks for duplicates and will only intern a given string once. Using the lasso/rodeo hack for packed maps. First param (“Key”) is the id and must be big enough to fit total items; Second param (“Idx”) is an index into the string and must be greater than string len.

Implementations§

Source§

impl<Key, Idx> PackedInterner<Key, Idx, BuildHasherDefault<FxHasher>>

Source

pub fn with_capacity_and_avg_len(cap: usize, avg_len: usize) -> Self

Source

pub fn with_capacity_and_str_len(cap: usize, str_len: usize) -> Self

Trait Implementations§

Source§

impl<Key: Debug, Idx: Debug, H: Debug> Debug for PackedInterner<Key, Idx, H>

Source§

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

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

impl<Key, Idx, H> From<PackedInterner<Key, Idx, H>> for Strs<Key, Idx>

Source§

fn from(val: PackedInterner<Key, Idx, H>) -> Self

Converts to this type from the input type.
Source§

impl<Key, Idx, H: BuildHasher> GetStr for PackedInterner<Key, Idx, H>
where KeyToStr<Key, Idx>: GetStr<Key = Key>,

Source§

type Key = Key

Key type used to fetch a string.
Source§

fn get(&self, k: Key) -> Result<&str>

Get the string associated with key k.
Source§

fn len(&self) -> usize

Total number of strings interned.
Source§

fn str_len(&self) -> usize

Size of interned strings.
Source§

fn is_empty(&self) -> bool

true if len is 0.
Source§

impl<Key, Idx, H: BuildHasher> InternStr for PackedInterner<Key, Idx, H>
where Key: Copy, KeyToStr<Key, Idx>: GetStr<Key = Key> + InternStr<Key = Key>,

Source§

type Key = Key

Key type returned from intern, can be used to fetch string later.
Source§

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

Intern string s and return a key that can be used to retrieve it later.

Auto Trait Implementations§

§

impl<Key, Idx, H> Freeze for PackedInterner<Key, Idx, H>
where H: Freeze,

§

impl<Key, Idx, H> RefUnwindSafe for PackedInterner<Key, Idx, H>

§

impl<Key, Idx, H> Send for PackedInterner<Key, Idx, H>
where H: Send, Key: Send, Idx: Send,

§

impl<Key, Idx, H> Sync for PackedInterner<Key, Idx, H>
where H: Sync, Key: Sync, Idx: Sync,

§

impl<Key, Idx, H> Unpin for PackedInterner<Key, Idx, H>
where H: Unpin, Key: Unpin, Idx: Unpin,

§

impl<Key, Idx, H> UnwindSafe for PackedInterner<Key, Idx, H>
where H: UnwindSafe, Key: UnwindSafe, Idx: UnwindSafe,

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.