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:
- T (
AnyType): A struct type.
Returns:
Variadic: A variadic of types, one for each field in the struct.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!