@@ -91,22 +91,6 @@ impl<'de> Visitor<'de> for Value {
9191 write ! ( formatter, "unrecognized value" )
9292 }
9393
94- fn visit_map < A > ( self , map : A ) -> Result < Self :: Value , A :: Error >
95- where
96- A : de:: MapAccess < ' de > ,
97- {
98- let mut fields: HashMap < String , Value > = HashMap :: new ( ) ;
99- let mut map = map;
100-
101- while let Some ( ( k, v) ) = map. next_entry ( ) . unwrap ( ) {
102- fields. insert ( k, v) ;
103- }
104-
105- Ok ( Value {
106- kind : Some ( Kind :: StructValue ( Struct { fields } ) ) ,
107- } )
108- }
109-
11094 fn visit_bool < E > ( self , v : bool ) -> Result < Self :: Value , E >
11195 where
11296 E : Error ,
@@ -134,21 +118,21 @@ impl<'de> Visitor<'de> for Value {
134118 } )
135119 }
136120
137- fn visit_unit < E > ( self ) -> Result < Self :: Value , E >
121+ fn visit_str < E > ( self , v : & str ) -> Result < Self :: Value , E >
138122 where
139123 E : Error ,
140124 {
141125 Ok ( Value {
142- kind : Some ( Kind :: NullValue ( 0 ) ) ,
126+ kind : Some ( Kind :: StringValue ( v . to_string ( ) ) ) ,
143127 } )
144128 }
145129
146- fn visit_str < E > ( self , v : & str ) -> Result < Self :: Value , E >
130+ fn visit_unit < E > ( self ) -> Result < Self :: Value , E >
147131 where
148132 E : Error ,
149133 {
150134 Ok ( Value {
151- kind : Some ( Kind :: StringValue ( v . to_string ( ) ) ) ,
135+ kind : Some ( Kind :: NullValue ( 0 ) ) ,
152136 } )
153137 }
154138
@@ -167,6 +151,22 @@ impl<'de> Visitor<'de> for Value {
167151 kind : Some ( Kind :: ListValue ( ListValue { values } ) ) ,
168152 } )
169153 }
154+
155+ fn visit_map < A > ( self , map : A ) -> Result < Self :: Value , A :: Error >
156+ where
157+ A : de:: MapAccess < ' de > ,
158+ {
159+ let mut fields: HashMap < String , Value > = HashMap :: new ( ) ;
160+ let mut map = map;
161+
162+ while let Some ( ( k, v) ) = map. next_entry ( ) . unwrap ( ) {
163+ fields. insert ( k, v) ;
164+ }
165+
166+ Ok ( Value {
167+ kind : Some ( Kind :: StructValue ( Struct { fields } ) ) ,
168+ } )
169+ }
170170}
171171
172172pub mod tests {
0 commit comments