Expand description
Immutable Map container backed by the C++ ffi.Map object.
The MapObj header mirrors C++ MapBaseObj, so Map::len reads size
directly (no FFI). The hash-table storage itself is an implementation detail,
so lookups and iteration are delegated to the global functions the C++ runtime
registers (ffi.MapGetItem, ffi.MapForwardIterFunctor, …): there is no
Map-specific C ABI, and a Rust re-implementation would have to replicate the
hashing (AnyHash/AnyEqual) and dense/small probing, just as the Python
bindings also delegate.
Any conversions follow C++ MapTypeTraitsBase (map_base.h): the strict
check walks every entry, and a failed strict try_from falls back to
converting the entries one by one into a new map.
Structs§
- Map
- Immutable, reference-counted map from
KtoV, sharing its underlyingMapObjwith C++. Cloning is cheap (it bumps the refcount). - MapIter
- Forward iterator over a
Map, yieldingTper entry. Thereadfn pulls the current entry (key, value, or both) from the C++ functor, so each variant touches only the command(s) it needs —keys()never reads values, and vice versa. Created via theMapItems/MapKeys/MapValuesaliases. - MapObj
- Container object for
Map. The header fields mirror C++MapBaseObj(include/tvm/ffi/container/map_base.h) soMap::lencan readsizewithout an FFI call; the storagedatapoints to stays opaque.