|
221 | 221 | //!
|
222 | 222 | //! 3. An asterisk `.*`:
|
223 | 223 | //!
|
224 |
| -//! `.*` means that this `{...}` is associated with *two* format inputs rather than one: the |
225 |
| -//! first input holds the `usize` precision, and the second holds the value to print. Note that |
226 |
| -//! in this case, if one uses the format string `{<arg>:<spec>.*}`, then the `<arg>` part refers |
227 |
| -//! to the *value* to print, and the `precision` must come in the input preceding `<arg>`. |
| 224 | +//! `.*` means that this `{...}` is associated with *two* format inputs rather than one: |
| 225 | +//! - If a format string in the fashion of `{:<spec>.*}` is used, then the first input holds |
| 226 | +//! the `usize` precision, and the second holds the value to print. |
| 227 | +//! - If a format string in the fashion of `{<arg>:<spec>.*}` is used, then the `<arg>` part |
| 228 | +//! refers to the value to print, and the `precision` is taken like it was specified with an |
| 229 | +//! omitted positional parameter (`{}` instead of `{<arg>:}`). |
228 | 230 | //!
|
229 | 231 | //! For example, the following calls all print the same thing `Hello x is 0.01000`:
|
230 | 232 | //!
|
|
242 | 244 | //! // specified in first of next two args (5)}
|
243 | 245 | //! println!("Hello {} is {:.*}", "x", 5, 0.01);
|
244 | 246 | //!
|
| 247 | +//! // Hello {arg 1 ("x")} is {arg 2 (0.01) with precision |
| 248 | +//! // specified in next arg (5)} |
| 249 | +//! println!("Hello {1} is {2:.*}", 5, "x", 0.01); |
| 250 | +//! |
245 | 251 | //! // Hello {next arg ("x")} is {arg 2 (0.01) with precision
|
246 |
| -//! // specified in its predecessor (5)} |
| 252 | +//! // specified in next arg (5)} |
247 | 253 | //! println!("Hello {} is {2:.*}", "x", 5, 0.01);
|
248 | 254 | //!
|
249 | 255 | //! // Hello {next arg ("x")} is {arg "number" (0.01) with precision specified
|
|
0 commit comments