pub struct TypeDef {
pub name: StructTypeName,
pub generic_params: Vec<TypeGenericParam>,
pub kind: TypeDefKind,
}Expand description
A registered type definition: either a required type stub or a tagged union.
Fields§
§name: StructTypeName§generic_params: Vec<TypeGenericParam>§kind: TypeDefKindImplementations§
Source§impl TypeDef
impl TypeDef
Sourcepub fn union_members(&self) -> Option<&[UnionMemberDef]>
pub fn union_members(&self) -> Option<&[UnionMemberDef]>
Returns the union members if this is a tagged union.
Returns None only for a required (unbound) type stub.
Sourcepub const fn is_union(&self) -> bool
pub const fn is_union(&self) -> bool
Returns true if this is a tagged union — single-variant or
multi-variant.
Sourcepub const fn is_required(&self) -> bool
pub const fn is_required(&self) -> bool
Returns true if this is a required type stub awaiting binding.
Sourcepub fn record_fields(&self) -> Option<&[StructField]>
pub fn record_fields(&self) -> Option<&[StructField]>
If this is a single-variant union whose sole constructor’s name equals the type’s name, returns that variant’s payload fields. This is the record-like shape: field access and brace construction work directly on it.
For multi-variant unions or single-variant unions whose
constructor name differs from the type name, returns None —
callers must dispatch through the constructor namespace and / or
match.
Sourcepub fn fields(&self) -> &[StructField]
pub fn fields(&self) -> &[StructField]
Backward-compatible accessor that returns the record-shaped
fields (empty when the type is multi-variant or a required
stub). Prefer record_fields at new call
sites — it makes the single-variant precondition explicit.