Skip to content

Commit ccdd7dd

Browse files
committed
Improve grammar in documentation of format strings
1 parent c4a73f7 commit ccdd7dd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

alloc/src/fmt.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,22 @@
282282
//! `%`. The actual grammar for the formatting syntax is:
283283
//!
284284
//! ```text
285-
//! format_string := <text> [ maybe-format <text> ] *
286-
//! maybe-format := '{' '{' | '}' '}' | <format>
285+
//! format_string := text [ maybe_format text ] *
286+
//! maybe_format := '{' '{' | '}' '}' | format
287287
//! format := '{' [ argument ] [ ':' format_spec ] '}'
288288
//! argument := integer | identifier
289289
//!
290-
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
290+
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
291291
//! fill := character
292292
//! align := '<' | '^' | '>'
293293
//! sign := '+' | '-'
294294
//! width := count
295295
//! precision := count | '*'
296-
//! type := identifier | '?' | ''
296+
//! type := '' | '?' | 'x?' | 'X?' | identifier
297297
//! count := parameter | integer
298298
//! parameter := argument '$'
299299
//! ```
300+
//! In the above grammar, `text` may not contain any `'{'` or `'}'` characters.
300301
//!
301302
//! # Formatting traits
302303
//!

0 commit comments

Comments
 (0)