diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2021-01-21 20:04:43 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-21 20:04:43 +0900 |
| commit | 8be36b1b3ac4cfe538ef8d32faeb1021407f55b2 (patch) | |
| tree | 3886456b2c539ac0513af42c3412f1a65344da99 /library/alloc/src | |
| parent | bcaf7dfc8f11edc82aeaf72270366236cdf5763d (diff) | |
| parent | 2eb4ccd3199f085b5863f85be11e552058ddaa24 (diff) | |
| download | rust-8be36b1b3ac4cfe538ef8d32faeb1021407f55b2.tar.gz rust-8be36b1b3ac4cfe538ef8d32faeb1021407f55b2.zip | |
Rollup merge of #80601 - steffahn:improve_format_string_grammar, r=m-ou-se
Improve grammar in documentation of format strings
The docs previously were
* using some weird `<` and `>` around some nonterminals
* _correct me if these **did** have any meaning_
* using of a (not explicitly defined) `text` nonterminal that didn’t explicitly disallow productions containing `'{'` or `'}'`
* incorrect in not allowing for `x?` and `X?` productions of `type`
* unnecessarily ambiguous, both
* allowing `type` to be `''`, and
* using an optional `[type]`
* using inconsistent underscore/hyphenation style between `format_string` and `format_spec` vs `maybe-format`
_Rendered:_

_(current docs: https://doc.rust-lang.org/nightly/std/fmt/#syntax)_
```@rustbot``` modify labels: T-doc
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/fmt.rs | 9 |
1 files 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 := <text> [ maybe-format <text> ] * -//! maybe-format := '{' '{' | '}' '}' | <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 //! |
