Skip to main content

Dict

Struct Dict 

Source
pub struct Dict<V: Copy, H: StrHash = MojoAHashStrHash, KC: TryInto<usize> + From<u8> + From<u16> + TryFrom<u32> + TryFrom<usize> + Copy + PartialEq = u32, KO: TryFrom<usize> + Copy + TryInto<usize> = u32, const DESTRUCTIVE: bool = true, const CACHING_HASHES: bool = true> { /* private fields */ }
Expand description

Open-addressing dictionary with linear probing and 1-based slot_to_index like your Mojo Dict.

  • V: Copy (to mirror Copyable & Movable)
  • H: BuildHasher/StrHash (default aHash RandomState)
  • KC: key-count integer (u32 default)
  • KO: key-offset integer for KeysContainer (u32 default)

Implementations§

Source§

impl<V: Copy, H: StrHash + Default, KC: TryInto<usize> + From<u8> + From<u16> + TryFrom<u32> + TryFrom<usize> + Copy + PartialEq, KO: TryFrom<usize> + Copy + TryInto<usize>, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>

Source

pub fn new(capacity: usize) -> Self

Source

pub fn len(&self) -> usize

Source

pub fn contains(&self, key: &str) -> bool

Source

pub fn put(&mut self, key: &str, value: V)

Source

pub fn get_or(&self, key: &str, default: V) -> V

Source

pub fn clear(&mut self)

Source

pub fn debug(&self)

Debug print similar to your debug() method.

Auto Trait Implementations§

§

impl<V, H, KC, KO, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> Freeze for Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>
where H: Freeze,

§

impl<V, H, KC, KO, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> RefUnwindSafe for Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>

§

impl<V, H, KC, KO, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> Send for Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>
where H: Send, V: Send, KC: Send, KO: Send,

§

impl<V, H, KC, KO, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> Sync for Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>
where H: Sync, V: Sync, KC: Sync, KO: Sync,

§

impl<V, H, KC, KO, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> Unpin for Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>
where H: Unpin, V: Unpin, KC: Unpin, KO: Unpin,

§

impl<V, H, KC, KO, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> UnsafeUnpin for Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>
where H: UnsafeUnpin,

§

impl<V, H, KC, KO, const DESTRUCTIVE: bool, const CACHING_HASHES: bool> UnwindSafe for Dict<V, H, KC, KO, DESTRUCTIVE, CACHING_HASHES>
where H: UnwindSafe, V: UnwindSafe, KC: UnwindSafe, KO: 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.