1
1
use std:: error:: Error ;
2
2
3
- use crate :: format;
4
3
use crate :: map:: Map ;
5
4
use crate :: value:: Value ;
6
5
@@ -9,8 +8,18 @@ pub(crate) fn parse(
9
8
text : & str ,
10
9
) -> Result < Map < String , Value > , Box < dyn Error + Send + Sync > > {
11
10
// 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
14
23
}
15
24
16
25
fn 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 {
21
30
toml:: Value :: Boolean ( value) => Value :: new ( uri, value) ,
22
31
23
32
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) ;
30
34
Value :: new ( uri, m)
31
35
}
32
36
0 commit comments