Skip to main content

Module optional

Module optional 

Source
Expand description

In-place mirror of C++ ffi::Optional<T> (include/tvm/ffi/optional.h).

C++ ffi::Optional<T> is uniformly backed by a single 16-byte TVMFFIAny regardless of T, with type_index == kTVMFFINone meaning nullopt. This makes the layout independent of the contained type, so a single Rust type mirrors every T.

Optional<T> is #[repr(transparent)] over Any (the same 16-byte TVMFFIAny cell) and decodes such a field’s bytes in place — no FFI call, no reflection getter/setter. It is named Optional (not Option) to distinguish it from Rust’s std::option::Option, matching the C++ ffi::Optional name.

It replaces the earlier per-T mirrors (OptionPod<T> / OptionStr / OptionObjRef<T>): those tracked the three now-removed C++ storage layouts (std::optional<T>, the String/Bytes sentinel cell, and an ObjectRef pointer). With the uniform TVMFFIAny backing they collapse into this one type.

Structs§

Optional
In-place mirror of C++ ffi::Optional<T>: a single 16-byte TVMFFIAny cell (wrapped as Any) whose type_index == kTVMFFINone encodes nullopt.