From 2eb4ccd3199f085b5863f85be11e552058ddaa24 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Fri, 1 Jan 2021 22:53:34 +0100 Subject: [PATCH] Improve grammar in documentation of format strings --- library/alloc/src/fmt.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs index 5ebc4d6c4c1..f9424b1d747 100644 --- a/library/alloc/src/fmt.rs +++ b/library/alloc/src/fmt.rs @@ -282,21 +282,22 @@ //! `%`. The actual grammar for the formatting syntax is: //! //! ```text -//! format_string := [ maybe-format ] * -//! maybe-format := '{' '{' | '}' '}' | +//! format_string := text [ maybe_format text ] * +//! maybe_format := '{' '{' | '}' '}' | format //! format := '{' [ argument ] [ ':' format_spec ] '}' //! argument := integer | identifier //! -//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type] +//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type //! fill := character //! align := '<' | '^' | '>' //! sign := '+' | '-' //! width := count //! precision := count | '*' -//! type := identifier | '?' | '' +//! type := '' | '?' | 'x?' | 'X?' | identifier //! count := parameter | integer //! parameter := argument '$' //! ``` +//! In the above grammar, `text` may not contain any `'{'` or `'}'` characters. //! //! # Formatting traits //!