@@ -22,26 +22,26 @@ fn from_ini(
22
22
uri : Option < & String > ,
23
23
data : Ini ,
24
24
) -> Value {
25
- let mut map = Map :: new ( ) ;
25
+ let mut map = Map :: < String , Value > :: new ( ) ;
26
26
27
27
let mut sections: Map < Option < & str > , Table > = data. into_iter ( ) . map ( |( section, props) | { (
28
28
section,
29
- props. iter ( ) . map ( |( k, v) | { (
30
- k. to_owned ( ) ,
31
- Value :: new ( uri, ValueKind :: String ( v. to_owned ( ) ) ) ,
32
- ) } ) . collect ( )
29
+ props. iter ( ) . map ( |( k, v) | {
30
+ let key = k. to_owned ( ) ;
31
+ let value = Value :: new ( uri, ValueKind :: String ( v. to_owned ( ) ) ) ;
32
+ ( key, value)
33
+ } ) . collect ( )
33
34
) } ) . collect ( ) ;
34
35
35
- // These (optional) properties should exist top-level alongside sections:
36
- if let Some ( sectionless) = sections. remove ( & None ) {
37
- map. extend ( sectionless) ;
38
- }
36
+ // Hoist (optional) sectionless properties to the top-level, alongside sections:
37
+ map. extend ( sections. remove ( & None ) . unwrap_or_default ( ) ) ;
39
38
40
39
// Wrap each section Table into Value for merging into `map`:
41
- map. extend ( sections. into_iter ( ) . map ( |( k, v) | { (
42
- k. unwrap_or_default ( ) . to_owned ( ) ,
43
- Value :: new ( uri, ValueKind :: Table ( v) ) ,
44
- ) } ) ) ;
40
+ map. extend ( sections. into_iter ( ) . map ( |( k, v) | {
41
+ let key = k. unwrap_or_default ( ) . to_owned ( ) ;
42
+ let value = Value :: new ( uri, ValueKind :: Table ( v) ) ;
43
+ ( key , value)
44
+ } ) ) ;
45
45
46
46
Value :: new ( uri, ValueKind :: Table ( map) )
47
47
}
0 commit comments