@@ -140,8 +140,8 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
140
140
output. push_str ( trimmed) ;
141
141
} else if matches ! ( state, State :: Expr ) {
142
142
extracted_expressions. push ( Arg :: Expr ( trimmed. into ( ) ) ) ;
143
- } else {
144
- extracted_expressions . push ( Arg :: Ident ( trimmed. into ( ) ) ) ;
143
+ } else if matches ! ( state , State :: Ident ) {
144
+ output . push_str ( trimmed) ;
145
145
}
146
146
147
147
output. push ( chr) ;
@@ -218,9 +218,9 @@ mod tests {
218
218
let test_vector = & [
219
219
( "no expressions" , expect ! [ [ "no expressions" ] ] ) ,
220
220
( r"no expressions with \$0$1" , expect ! [ r"no expressions with \\\$0\$1" ] ) ,
221
- ( "{expr} is {2 + 2}" , expect ! [ [ "{} is {}; expr, 2 + 2" ] ] ) ,
222
- ( "{expr:?}" , expect ! [ [ "{:?}; expr " ] ] ) ,
223
- ( "{expr:1$}" , expect ! [ [ r"{:1\$}; expr " ] ] ) ,
221
+ ( "{expr} is {2 + 2}" , expect ! [ [ "{expr } is {}; 2 + 2" ] ] ) ,
222
+ ( "{expr:?}" , expect ! [ [ "{expr :?}" ] ] ) ,
223
+ ( "{expr:1$}" , expect ! [ [ r"{expr :1\$}" ] ] ) ,
224
224
( "{:1$}" , expect ! [ [ r"{:1\$}; $1" ] ] ) ,
225
225
( "{:>padding$}" , expect ! [ [ r"{:>padding\$}; $1" ] ] ) ,
226
226
( "{}, {}, {0}" , expect ! [ [ r"{}, {}, {0}; $1, $2" ] ] ) ,
@@ -230,16 +230,16 @@ mod tests {
230
230
( "malformed}" , expect ! [ [ "-" ] ] ) ,
231
231
( "{{correct" , expect ! [ [ "{{correct" ] ] ) ,
232
232
( "correct}}" , expect ! [ [ "correct}}" ] ] ) ,
233
- ( "{correct}}}" , expect ! [ [ "{}}}; correct " ] ] ) ,
234
- ( "{correct}}}}}" , expect ! [ [ "{}}}}}; correct " ] ] ) ,
233
+ ( "{correct}}}" , expect ! [ [ "{correct }}}" ] ] ) ,
234
+ ( "{correct}}}}}" , expect ! [ [ "{correct }}}}}" ] ] ) ,
235
235
( "{incorrect}}" , expect ! [ [ "-" ] ] ) ,
236
236
( "placeholders {} {}" , expect ! [ [ "placeholders {} {}; $1, $2" ] ] ) ,
237
237
( "mixed {} {2 + 2} {}" , expect ! [ [ "mixed {} {} {}; $1, 2 + 2, $2" ] ] ) ,
238
238
(
239
239
"{SomeStruct { val_a: 0, val_b: 1 }}" ,
240
240
expect ! [ [ "{}; SomeStruct { val_a: 0, val_b: 1 }" ] ] ,
241
241
) ,
242
- ( "{expr:?} is {2.32f64:.5}" , expect ! [ [ "{:?} is {:.5}; expr, 2.32f64" ] ] ) ,
242
+ ( "{expr:?} is {2.32f64:.5}" , expect ! [ [ "{expr :?} is {:.5}; 2.32f64" ] ] ) ,
243
243
(
244
244
"{SomeStruct { val_a: 0, val_b: 1 }:?}" ,
245
245
expect ! [ [ "{:?}; SomeStruct { val_a: 0, val_b: 1 }" ] ] ,
0 commit comments