Mojo struct
DictEntry
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
Methods
__init__
__init__(inout self: 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__(inout self: Self, *, other: Self)
Copy an existing entry.
Args:
- other (
Self
): The existing entry to copy.
reap_value
reap_value(owned self: 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!
😔 What went wrong?