toml: add doc string to reflect methods (#12666)

pull/12714/head
Larpon 2021-12-03 22:07:44 +01:00 committed by GitHub
parent 33163238e7
commit 7e6d4ebfe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -227,6 +227,8 @@ fn (a Any) value_(value Any, key []string) Any {
}
}
// reflect returns `T` with `T.<field>`'s value set to the
// value of any 1st level TOML key by the same name.
pub fn (a Any) reflect<T>() T {
mut reflected := T{}
$for field in T.fields {

View File

@ -173,6 +173,8 @@ pub fn (d Doc) to_any() Any {
return ast_to_any(d.ast.table)
}
// reflect returns `T` with `T.<field>`'s value set to the
// value of any 1st level TOML key by the same name.
pub fn (d Doc) reflect<T>() T {
return d.to_any().reflect<T>()
}