Skip to main content

Module optional

Module optional 

Source
Expand description

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

C++ ffi::Optional<T> is backed by one 16-byte TVMFFIAny for scalar, string, and other non-object-pointer values, with type_index == kTVMFFINone meaning nullopt. Optional<T> mirrors that representation.

ObjectRef, ObjectPtr, and Arc cases are intentionally excluded. Their C++ optional is one nullable object pointer, which Rust’s niche-optimized std::option::Option<X> already mirrors. Using Optional<X> for an object class is rejected at compile time so the two ABI layouts cannot be confused.

Optional<T> is #[repr(transparent)] over Any and decodes the cell in place. It is named Optional (not Option) to match the C++ type while keeping the pointer-backed object case visually distinct.

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.

Traits§

OptionalCompatible
Marker for values whose C++ ffi::Optional<T> uses the 16-byte TVMFFIAny representation.