Skip to main content

Mojo function

get_struct_field_types

get_struct_field_types[T: AnyType]() -> Variadic[AnyTrivialRegType]

Returns the types of all fields in struct T as a variadic.

This function provides compile-time reflection over struct fields. It returns the types of all fields (including private fields) in declaration order.

For nested structs, this returns the struct type itself, not its flattened fields. Use recursive calls to introspect nested types.

Parameters:

Returns:

Variadic: A variadic of types, one for each field in the struct.

Was this page helpful?