Variant module

Variant

structextensionsince 0.29.0Source

A value that holds one of types at a time. A fresh one holds a zeroed first case; it takes the size of the largest case.

Example↗
#import "Extensions/Variant";

Id :: Variant(s64, string);
id: Id;
assert(is(id, s64) && variant_index(id) == 0);
set(*id, "abc");
assert(variant_index(id) == 1);

Fields

index: s32
The position of the live case in types.