Felt252Dict
.
When working with dictionaries in Cairo, we need a way to represent “empty” or “uninitialized”
slots. This trait provides a zero-like default value that is returned when accessing a key
that hasn’t been explicitly set.
Felt252Dict
implementation needs to handle cases where a key hasn’t been assigned a value
yet.
Instead of using Option
or similar constructs, it uses a zero-like value specific to each
type.
This trait is only implemented for primitive scalar types and Nullable
. It cannot be
implemented manually.
Instead, if you want to use a custom type as a value in a dictionary, you can wrap your type in
a Nullable
, which implements Felt252DictValue
for any wrapped type.Felt252Dict
.
This value should be logically equivalent to zero or an “empty” state.