Skip to main content

Mojo struct

DictEntry

struct DictEntry[K: Copyable & Movable & Hashable & EqualityComparable, V: Copyable & Movable, H: Hasher]

Store a key-value pair entry inside a dictionary.

Parameters

Fields

  • hash (SIMD[uint64, 1]): key.__hash__(), stored so hashing isn't re-computed during dict lookup.
  • key (K): The unique key for the entry.
  • value (V): The value associated with the key.

Implemented traits

AnyType, Copyable, ExplicitlyCopyable, Movable, UnknownDestructibility

Methods

__init__

__init__(out self, var key: K, var value: V)

Create an entry from a key and value, computing the hash.

Args:

  • key (K): The key of the entry.
  • value (V): The value of the entry.

copy

copy(self) -> Self

Copy an existing entry.

Returns:

Self: A copy of the value.

reap_value

reap_value(var self) -> V

Take the value from an owned entry.

Returns:

V: The value of the entry.

Was this page helpful?