Mojo struct
DictEntry
struct DictEntry[K: KeyElement, V: CollectionElement]
Store a key-value pair entry inside a dictionary.
Parameters
- K (
KeyElement
): The key type of the dict. Must be Hashable+EqualityComparable. - V (
CollectionElement
): The value type of the dict.
Fields
- hash (
Int
):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
,
CollectionElement
,
CollectionElementNew
,
Copyable
,
ExplicitlyCopyable
,
Movable
,
UnknownDestructibility
Methods
__init__
__init__(out self, owned key: K, owned 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.
__init__(out self, *, other: Self)
Copy an existing entry.
Args:
- other (
Self
): The existing entry to copy.
reap_value
reap_value(owned self) -> V
Take the value from an owned entry.
Returns:
The value of the entry.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!