Skip to content

Commit a14601e

Browse files
committed
std::fmt: move format string grammar to the bottom
1 parent d4f7f97 commit a14601e

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

src/liballoc/fmt.rs

+25-24
Original file line numberDiff line numberDiff line change
@@ -300,30 +300,6 @@
300300
//! it would internally pass around this structure until it has been determined
301301
//! where output should go to.
302302
//!
303-
//! # Syntax
304-
//!
305-
//! The syntax for the formatting language used is drawn from other languages,
306-
//! so it should not be too alien. Arguments are formatted with Python-like
307-
//! syntax, meaning that arguments are surrounded by `{}` instead of the C-like
308-
//! `%`. The actual grammar for the formatting syntax is:
309-
//!
310-
//! ```text
311-
//! format_string := <text> [ maybe-format <text> ] *
312-
//! maybe-format := '{' '{' | '}' '}' | <format>
313-
//! format := '{' [ argument ] [ ':' format_spec ] '}'
314-
//! argument := integer | identifier
315-
//!
316-
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
317-
//! fill := character
318-
//! align := '<' | '^' | '>'
319-
//! sign := '+' | '-'
320-
//! width := count
321-
//! precision := count | '*'
322-
//! type := identifier | '?' | ''
323-
//! count := parameter | integer
324-
//! parameter := argument '$'
325-
//! ```
326-
//!
327303
//! # Formatting Parameters
328304
//!
329305
//! Each argument being formatted can be transformed by a number of formatting
@@ -479,6 +455,31 @@
479455
//! them with the same character. For example, the `{` character is escaped with
480456
//! `{{` and the `}` character is escaped with `}}`.
481457
//!
458+
//! # Syntax
459+
//!
460+
//! Below, you can find the full grammar of format strings.
461+
//! The syntax for the formatting language used is drawn from other languages,
462+
//! so it should not be too alien. Arguments are formatted with Python-like
463+
//! syntax, meaning that arguments are surrounded by `{}` instead of the C-like
464+
//! `%`. The actual grammar for the formatting syntax is:
465+
//!
466+
//! ```text
467+
//! format_string := <text> [ maybe-format <text> ] *
468+
//! maybe-format := '{' '{' | '}' '}' | <format>
469+
//! format := '{' [ argument ] [ ':' format_spec ] '}'
470+
//! argument := integer | identifier
471+
//!
472+
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
473+
//! fill := character
474+
//! align := '<' | '^' | '>'
475+
//! sign := '+' | '-'
476+
//! width := count
477+
//! precision := count | '*'
478+
//! type := identifier | '?' | ''
479+
//! count := parameter | integer
480+
//! parameter := argument '$'
481+
//! ```
482+
//!
482483
//! [`usize`]: ../../std/primitive.usize.html
483484
//! [`isize`]: ../../std/primitive.isize.html
484485
//! [`i8`]: ../../std/primitive.i8.html

0 commit comments

Comments
 (0)