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")))
}Вывод
id=7;name=ann;
@intrinsic("reflect") pub(api) comptime fn reflect(T: i32) -> TypeInfoСложность. evaluated at compile time; no run-time cost.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
T | i32 |
Возвращает
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/reflect/reflect.oxl:202