Skip to main content

Module map

Module map 

Source
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 K to V, sharing its underlying MapObj with C++. Cloning is cheap (it bumps the refcount).
MapIter
Forward iterator over a Map, yielding T per entry. The read fn 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 the MapItems / MapKeys / MapValues aliases.
MapObj
Container object for Map. The header fields mirror C++ MapBaseObj (include/tvm/ffi/container/map_base.h) so Map::len can read size without an FFI call; the storage data points to stays opaque.

Type Aliases§

MapItems
Iterator over (key, value) pairs, created by Map::iter.
MapKeys
Iterator over keys, created by Map::keys.
MapValues
Iterator over values, created by Map::values.