11use std:: error:: Error ;
22
3- use crate :: format;
43use crate :: map:: Map ;
54use crate :: value:: Value ;
65
@@ -9,8 +8,18 @@ pub(crate) fn parse(
98 text : & str ,
109) -> Result < Map < String , Value > , Box < dyn Error + Send + Sync > > {
1110 // Parse a TOML value from the provided text
12- let value = from_toml_value ( uri, & toml:: from_str ( text) ?) ;
13- format:: extract_root_table ( uri, value)
11+ let table = from_toml_table ( uri, & toml:: from_str ( text) ?) ;
12+ Ok ( table)
13+ }
14+
15+ fn from_toml_table ( uri : Option < & String > , table : & toml:: Table ) -> Map < String , Value > {
16+ let mut m = Map :: new ( ) ;
17+
18+ for ( key, value) in table {
19+ m. insert ( key. clone ( ) , from_toml_value ( uri, value) ) ;
20+ }
21+
22+ m
1423}
1524
1625fn from_toml_value ( uri : Option < & String > , value : & toml:: Value ) -> Value {
@@ -21,12 +30,7 @@ fn from_toml_value(uri: Option<&String>, value: &toml::Value) -> Value {
2130 toml:: Value :: Boolean ( value) => Value :: new ( uri, value) ,
2231
2332 toml:: Value :: Table ( ref table) => {
24- let mut m = Map :: new ( ) ;
25-
26- for ( key, value) in table {
27- m. insert ( key. clone ( ) , from_toml_value ( uri, value) ) ;
28- }
29-
33+ let m = from_toml_table ( uri, table) ;
3034 Value :: new ( uri, m)
3135 }
3236
0 commit comments