Skip to main content

praxis_alloc_enum

Function praxis_alloc_enum 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn praxis_alloc_enum( ctx: *mut RuntimeContext, schema_ptr: *const EnumSchema, tag: i64, ) -> GcRef
Expand description

Allocate an enum value (§4.6) of the type schema_ptr describes, with variant tag and every payload slot initialized to Unit. Payload values are filled via praxis_enum_set_payload after allocation. Returns the enum GcRef.

The arity is read from the schema rather than passed alongside it, as praxis_alloc_tuple already does: a schema and an arity that disagree is a state no caller can now reach. A null schema, or a tag the schema has no variant for, allocates nothing and answers the Unit sentinel — the same answer praxis_alloc_tuple gives a null schema.

§Safety

ctx must be live and wired; schema_ptr must be null or a valid 'static pointer.