@@ -33,29 +33,21 @@ impl Container<'_> {
33
33
} ;
34
34
35
35
match self {
36
- Self :: NamedStruct { fields } => {
36
+ Self :: NamedStruct { fields } | Self :: UnnamedStruct { fields } => {
37
37
for field in fields {
38
- let name = field. get_name ( Some ( & field. casing_format ) ) ;
38
+ let name = if field. name . is_some ( ) {
39
+ field. get_name ( Some ( & field. casing_format ) )
40
+ } else {
41
+ field. index . to_string ( )
42
+ } ;
39
43
let env_key = if let Some ( value) = field. get_env_var ( ) {
40
44
quote ! ( Some ( #value. into( ) ) )
41
45
} else {
42
46
quote ! ( None )
43
47
} ;
44
- let type_alias = format_alias ( field. value . to_token_stream ( ) ) ;
45
-
46
- settings. push ( quote ! {
47
- ( #name. into( ) , schematic:: ConfigSetting {
48
- env_key: #env_key,
49
- type_alias: #type_alias. into( ) ,
50
- } ) ,
51
- } ) ;
52
- }
53
- }
54
- Self :: UnnamedStruct { fields } => {
55
- for field in fields {
56
- let name = field. index . to_string ( ) ;
57
- let env_key = if let Some ( value) = field. get_env_var ( ) {
58
- quote ! ( Some ( #value. into( ) ) )
48
+ let nested = if field. is_nested ( ) {
49
+ let value = field. value_type . get_config_type ( ) ;
50
+ quote ! ( Some ( #value:: settings( ) ) )
59
51
} else {
60
52
quote ! ( None )
61
53
} ;
@@ -64,6 +56,7 @@ impl Container<'_> {
64
56
settings. push ( quote ! {
65
57
( #name. into( ) , schematic:: ConfigSetting {
66
58
env_key: #env_key,
59
+ nested: #nested,
67
60
type_alias: #type_alias. into( ) ,
68
61
} ) ,
69
62
} ) ;
@@ -76,16 +69,16 @@ impl Container<'_> {
76
69
77
70
settings. push ( quote ! {
78
71
( #name. into( ) , schematic:: ConfigSetting {
79
- env_key: None ,
80
72
type_alias: #type_alias. into( ) ,
73
+ ..Default :: default ( )
81
74
} ) ,
82
75
} ) ;
83
76
}
84
77
}
85
78
} ;
86
79
87
80
quote ! {
88
- std:: collections:: HashMap :: from_iter( [
81
+ std:: collections:: BTreeMap :: from_iter( [
89
82
#( #settings) *
90
83
] )
91
84
}
0 commit comments