Mojo struct
ReflectedType
@register_passable(trivial)
struct ReflectedType[T: AnyTrivialRegType]
Wrapper struct for compile-time type values from reflection.
This struct wraps a !kgen.type value as a type parameter, allowing
type values to be returned from functions and passed around at compile time.
Example:
# Get the type of field "x" in MyStruct
comptime field_type = struct_field_type_by_name[MyStruct, "x"]()
# Access the underlying type via the T parameter
var value: field_type.T = 42Parameters
- T (
AnyTrivialRegType): The wrapped type value.
Implemented traits
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDestructible,
Movable
comptime members
__copyinit__is_trivial
comptime __copyinit__is_trivial = True
__del__is_trivial
comptime __del__is_trivial = True
__moveinit__is_trivial
comptime __moveinit__is_trivial = True
Methods
__init__
__init__() -> Self
Create a ReflectedType instance.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!