mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix enum handling
This commit is contained in:
parent
3b47254dd8
commit
b1df64b002
@ -19,8 +19,7 @@ pub fn decode[T](toml_txt string) !T {
|
||||
mut typ := T{}
|
||||
$for field in T.fields {
|
||||
$if field.is_enum {
|
||||
// TODO: check enums
|
||||
doc.value(field.name).int()
|
||||
typ.$(field.name) = doc.value(field.name).int()
|
||||
} $else $if field.typ is string {
|
||||
typ.$(field.name) = doc.value(field.name).string()
|
||||
} $else $if field.typ is bool {
|
||||
@ -51,7 +50,7 @@ pub fn encode[T](typ T) string {
|
||||
$for field in T.fields {
|
||||
value := typ.$(field.name)
|
||||
$if field.is_enum {
|
||||
mp[field.name] = Any(value.str())
|
||||
mp[field.name] = Any(int(value))
|
||||
} $else {
|
||||
mp[field.name] = Any(value)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user