@@ -140,8 +140,8 @@ pub fn parse_format_exprs(input: &str) -> Result<(String, Vec<Arg>), ()> {
140140 output. push_str ( trimmed) ;
141141 } else if matches ! ( state, State :: Expr ) {
142142 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) ;
145145 }
146146
147147 output. push ( chr) ;
@@ -218,9 +218,9 @@ mod tests {
218218 let test_vector = & [
219219 ( "no expressions" , expect ! [ [ "no expressions" ] ] ) ,
220220 ( 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\$}" ] ] ) ,
224224 ( "{:1$}" , expect ! [ [ r"{:1\$}; $1" ] ] ) ,
225225 ( "{:>padding$}" , expect ! [ [ r"{:>padding\$}; $1" ] ] ) ,
226226 ( "{}, {}, {0}" , expect ! [ [ r"{}, {}, {0}; $1, $2" ] ] ) ,
@@ -230,16 +230,16 @@ mod tests {
230230 ( "malformed}" , expect ! [ [ "-" ] ] ) ,
231231 ( "{{correct" , expect ! [ [ "{{correct" ] ] ) ,
232232 ( "correct}}" , expect ! [ [ "correct}}" ] ] ) ,
233- ( "{correct}}}" , expect ! [ [ "{}}}; correct " ] ] ) ,
234- ( "{correct}}}}}" , expect ! [ [ "{}}}}}; correct " ] ] ) ,
233+ ( "{correct}}}" , expect ! [ [ "{correct }}}" ] ] ) ,
234+ ( "{correct}}}}}" , expect ! [ [ "{correct }}}}}" ] ] ) ,
235235 ( "{incorrect}}" , expect ! [ [ "-" ] ] ) ,
236236 ( "placeholders {} {}" , expect ! [ [ "placeholders {} {}; $1, $2" ] ] ) ,
237237 ( "mixed {} {2 + 2} {}" , expect ! [ [ "mixed {} {} {}; $1, 2 + 2, $2" ] ] ) ,
238238 (
239239 "{SomeStruct { val_a: 0, val_b: 1 }}" ,
240240 expect ! [ [ "{}; SomeStruct { val_a: 0, val_b: 1 }" ] ] ,
241241 ) ,
242- ( "{expr:?} is {2.32f64:.5}" , expect ! [ [ "{:?} is {:.5}; expr, 2.32f64" ] ] ) ,
242+ ( "{expr:?} is {2.32f64:.5}" , expect ! [ [ "{expr :?} is {:.5}; 2.32f64" ] ] ) ,
243243 (
244244 "{SomeStruct { val_a: 0, val_b: 1 }:?}" ,
245245 expect ! [ [ "{:?}; SomeStruct { val_a: 0, val_b: 1 }" ] ] ,
0 commit comments