std::fmt: Fix the grammar documentation
According to the grammar documented, the format specifier `{: }` should not be legal because of the whitespace it contains. However, in reality, this is perfectly fine because the actual implementation allows spaces before the closing brace. Fixes #71088. Also, the exact meaning of most of the terminal symbols was not specified, for example the meaning of `identifier`.
This commit is contained in:
parent
afd80a21b0
commit
79d9afda13
1 changed files with 7 additions and 2 deletions
|
@ -310,7 +310,7 @@
|
|||
//! ```text
|
||||
//! format_string := text [ maybe_format text ] *
|
||||
//! maybe_format := '{' '{' | '}' '}' | format
|
||||
//! format := '{' [ argument ] [ ':' format_spec ] '}'
|
||||
//! format := '{' [ argument ] [ ':' format_spec ] [ ws ] * '}'
|
||||
//! argument := integer | identifier
|
||||
//!
|
||||
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
|
||||
|
@ -323,7 +323,12 @@
|
|||
//! count := parameter | integer
|
||||
//! parameter := argument '$'
|
||||
//! ```
|
||||
//! In the above grammar, `text` must not contain any `'{'` or `'}'` characters.
|
||||
//! In the above grammar,
|
||||
//! - `text` must not contain any `'{'` or `'}'` characters,
|
||||
//! - `ws` is any character for which [`char::is_whitespace`] returns `true`, has no semantic
|
||||
//! meaning and is completely optional,
|
||||
//! - `integer` is a decimal integer that may contain leading zeroes and
|
||||
//! - `identifier` is an `IDENTIFIER_OR_KEYWORD` (not an `IDENTIFIER`) as defined by the [Rust language reference](https://doc.rust-lang.org/reference/identifiers.html).
|
||||
//!
|
||||
//! # Formatting traits
|
||||
//!
|
||||
|
|
Loading…
Add table
Reference in a new issue