IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

ReflectedType

struct ReflectedType[T: AnyType]

Deprecated: use Reflected[T] from std.reflection instead.

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

Deprecated: Use Reflected[T] from std.reflection instead.

Parameters

  • T (AnyType): The wrapped type value.

Implemented traits

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

Methods

__init__

__init__() -> Self

Create a ReflectedType instance.