@@ -235,35 +235,40 @@ pub(crate) trait HasFieldMap {
235235 // the referenced fields. Leaves `it` sitting on the closing brace of the format string, so
236236 // the next call to `it.next()` retrieves the next character.
237237 while let Some ( c) = it. next ( ) {
238- if c == '{' && * it. peek ( ) . unwrap_or ( & '\0' ) != '{' {
239- let mut eat_argument = || -> Option < String > {
240- let mut result = String :: new ( ) ;
241- // Format specifiers look like:
242- //
243- // format := '{' [ argument ] [ ':' format_spec ] '}' .
244- //
245- // Therefore, we only need to eat until ':' or '}' to find the argument.
246- while let Some ( c) = it. next ( ) {
247- result. push ( c) ;
248- let next = * it. peek ( ) . unwrap_or ( & '\0' ) ;
249- if next == '}' {
250- break ;
251- } else if next == ':' {
252- // Eat the ':' character.
253- assert_eq ! ( it. next( ) . unwrap( ) , ':' ) ;
254- break ;
255- }
256- }
257- // Eat until (and including) the matching '}'
258- while it. next ( ) ? != '}' {
259- continue ;
238+ if c != '{' {
239+ continue ;
240+ }
241+ if * it. peek ( ) . unwrap_or ( & '\0' ) == '{' {
242+ assert_eq ! ( it. next( ) . unwrap( ) , '{' ) ;
243+ continue ;
244+ }
245+ let mut eat_argument = || -> Option < String > {
246+ let mut result = String :: new ( ) ;
247+ // Format specifiers look like:
248+ //
249+ // format := '{' [ argument ] [ ':' format_spec ] '}' .
250+ //
251+ // Therefore, we only need to eat until ':' or '}' to find the argument.
252+ while let Some ( c) = it. next ( ) {
253+ result. push ( c) ;
254+ let next = * it. peek ( ) . unwrap_or ( & '\0' ) ;
255+ if next == '}' {
256+ break ;
257+ } else if next == ':' {
258+ // Eat the ':' character.
259+ assert_eq ! ( it. next( ) . unwrap( ) , ':' ) ;
260+ break ;
260261 }
261- Some ( result)
262- } ;
263-
264- if let Some ( referenced_field) = eat_argument ( ) {
265- referenced_fields. insert ( referenced_field) ;
266262 }
263+ // Eat until (and including) the matching '}'
264+ while it. next ( ) ? != '}' {
265+ continue ;
266+ }
267+ Some ( result)
268+ } ;
269+
270+ if let Some ( referenced_field) = eat_argument ( ) {
271+ referenced_fields. insert ( referenced_field) ;
267272 }
268273 }
269274
0 commit comments