fn reflect
reflect(T); expanded by the compiler, never called at run time.
Example:
use std.reflect { reflect }
data Row {
id: i64
name: str
}
fn describe(r: &Row) -> String {
var out = String.new()
inline for f in reflect(Row).fields {
out.push("{f.name}={r.[f]};")
}
out
}
fn main() io {
print(describe(&Row(id: 7, name: "ann")))
}Output
id=7;name=ann;
@intrinsic("reflect") pub(api) comptime fn reflect(T: i32) -> TypeInfoComplexity. evaluated at compile time; no run-time cost.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
T | i32 |
Returns
Effects
none declared (pure unless the body says otherwise)
Defined in: std/reflect/reflect.oxl:202