Skip to main content
Version: Nightly

ReflectedType

struct ReflectedType[T: AnyType]

Wrapper struct for compile-time type values from reflection.

This struct wraps a !kgen.non_struct_type value as a type parameter, allowing type values to be returned from functions and passed around at compile time.

Example:

from std.reflection import struct_field_type_by_name

struct MyStruct:
var x: Int
var y: Float64

def main():
# 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 = 42

Parameters

  • T (AnyType): The wrapped type value.

Implemented traits

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable, RegisterPassable, TrivialRegisterPassable

Methods

__init__

__init__() -> Self

Create a ReflectedType instance.