@@ -152,6 +152,8 @@ where
152
152
153
153
impl Display for ValueKind {
154
154
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
155
+ use std:: fmt:: Write ;
156
+
155
157
match * self {
156
158
Self :: String ( ref value) => write ! ( f, "{}" , value) ,
157
159
Self :: Boolean ( value) => write ! ( f, "{}" , value) ,
@@ -161,15 +163,20 @@ impl Display for ValueKind {
161
163
Self :: U128 ( value) => write ! ( f, "{}" , value) ,
162
164
Self :: Float ( value) => write ! ( f, "{}" , value) ,
163
165
Self :: Nil => write ! ( f, "nil" ) ,
164
- Self :: Table ( ref table) => write ! ( f, "{{ {} }}" , {
165
- table
166
- . iter( )
167
- . map( |( k, v) | format!( "{} => {}, " , k, v) )
168
- . collect:: <String >( )
169
- } ) ,
170
- Self :: Array ( ref array) => write ! ( f, "{:?}" , {
171
- array. iter( ) . map( |e| format!( "{}, " , e) ) . collect:: <String >( )
172
- } ) ,
166
+ Self :: Table ( ref table) => {
167
+ let mut s = String :: new ( ) ;
168
+ for ( k, v) in table. iter ( ) {
169
+ write ! ( s, "{} => {}, " , k, v) ?
170
+ }
171
+ write ! ( f, "{{ {s} }}" )
172
+ }
173
+ Self :: Array ( ref array) => {
174
+ let mut s = String :: new ( ) ;
175
+ for e in array. iter ( ) {
176
+ write ! ( s, "{}, " , e) ?;
177
+ }
178
+ write ! ( f, "{s:?}" )
179
+ }
173
180
}
174
181
}
175
182
}
0 commit comments