about summary refs log tree commit diff
diff options
context:
space:
mode:
authorElias Holzmann <9659253+EliasHolzmann@users.noreply.github.com>2022-04-30 02:39:27 +0200
committerElias Holzmann <9659253+EliasHolzmann@users.noreply.github.com>2022-05-01 15:27:40 +0200
commitafd80a21b0fd2fb378e01a49b95d9a7d61536ca6 (patch)
treefbc2e4e174880d5ff5ae001a7d88dfb7104557c8
parent1288883932e04317cbf075989cfc17369bff038c (diff)
downloadrust-afd80a21b0fd2fb378e01a49b95d9a7d61536ca6.tar.gz
rust-afd80a21b0fd2fb378e01a49b95d9a7d61536ca6.zip
std::fmt: Added argument index comments to examples for specifying precision
The examples for specifying the precision have comments explaining which
argument the specifier is referring to. However, for implicit positional
arguments, the examples simply talk about "next arg". To make it easier for
readers to follow the comments, "next arg" was supplemented with the actual
resulting argument index.
-rw-r--r--library/alloc/src/fmt.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/library/alloc/src/fmt.rs b/library/alloc/src/fmt.rs
index 5f6849a9b63..361e821dd37 100644
--- a/library/alloc/src/fmt.rs
+++ b/library/alloc/src/fmt.rs
@@ -240,19 +240,19 @@
 //! // Hello {arg 0 ("x")} is {arg 2 (0.01) with precision specified in arg 1 (5)}
 //! println!("Hello {0} is {2:.1$}", "x", 5, 0.01);
 //!
-//! // Hello {next arg ("x")} is {second of next two args (0.01) with precision
-//! //                          specified in first of next two args (5)}
+//! // Hello {next arg -> arg 0 ("x")} is {second of next two args -> arg 2 (0.01) with precision
+//! //                          specified in first of next two args -> arg 1 (5)}
 //! println!("Hello {} is {:.*}",    "x", 5, 0.01);
 //!
 //! // Hello {arg 1 ("x")} is {arg 2 (0.01) with precision
-//! //                          specified in next arg (5)}
+//! //                          specified in next arg -> arg 0 (5)}
 //! println!("Hello {1} is {2:.*}",  5, "x", 0.01);
 //!
-//! // Hello {next arg ("x")} is {arg 2 (0.01) with precision
-//! //                          specified in next arg (5)}
+//! // Hello {next arg -> arg 0 ("x")} is {arg 2 (0.01) with precision
+//! //                          specified in next arg -> arg 1 (5)}
 //! println!("Hello {} is {2:.*}",   "x", 5, 0.01);
 //!
-//! // Hello {next arg ("x")} is {arg "number" (0.01) with precision specified
+//! // Hello {next arg -> arg 0 ("x")} is {arg "number" (0.01) with precision specified
 //! //                          in arg "prec" (5)}
 //! println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
 //! ```