|
434 | 434 | //! in this case, if one uses the format string `{<arg>:<spec>.*}`, then the `<arg>` part refers
|
435 | 435 | //! to the *value* to print, and the `precision` must come in the input preceding `<arg>`.
|
436 | 436 | //!
|
437 |
| -//! For example, these: |
| 437 | +//! For example, the following calls all print the same thing `Hello x is 0.01000`: |
438 | 438 | //!
|
439 | 439 | //! ```
|
440 |
| -//! // Hello {arg 0 (x)} is {arg 1 (0.01) with precision specified inline (5)} |
| 440 | +//! // Hello {arg 0 ("x")} is {arg 1 (0.01) with precision specified inline (5)} |
441 | 441 | //! println!("Hello {0} is {1:.5}", "x", 0.01);
|
442 | 442 | //!
|
443 |
| -//! // Hello {arg 1 (x)} is {arg 2 (0.01) with precision specified in arg 0 (5)} |
| 443 | +//! // Hello {arg 1 ("x")} is {arg 2 (0.01) with precision specified in arg 0 (5)} |
444 | 444 | //! println!("Hello {1} is {2:.0$}", 5, "x", 0.01);
|
445 | 445 | //!
|
446 |
| -//! // Hello {arg 0 (x)} is {arg 2 (0.01) with precision specified in arg 1 (5)} |
| 446 | +//! // Hello {arg 0 ("x")} is {arg 2 (0.01) with precision specified in arg 1 (5)} |
447 | 447 | //! println!("Hello {0} is {2:.1$}", "x", 5, 0.01);
|
448 | 448 | //!
|
449 |
| -//! // Hello {next arg (x)} is {second of next two args (0.01) with precision |
| 449 | +//! // Hello {next arg ("x")} is {second of next two args (0.01) with precision |
450 | 450 | //! // specified in first of next two args (5)}
|
451 | 451 | //! println!("Hello {} is {:.*}", "x", 5, 0.01);
|
452 | 452 | //!
|
453 |
| -//! // Hello {next arg (x)} is {arg 2 (0.01) with precision |
| 453 | +//! // Hello {next arg ("x")} is {arg 2 (0.01) with precision |
454 | 454 | //! // specified in its predecessor (5)}
|
455 | 455 | //! println!("Hello {} is {2:.*}", "x", 5, 0.01);
|
456 | 456 | //!
|
457 |
| -//! // Hello {next arg (x)} is {arg "number" (0.01) with precision specified |
| 457 | +//! // Hello {next arg ("x")} is {arg "number" (0.01) with precision specified |
458 | 458 | //! // in arg "prec" (5)}
|
459 | 459 | //! println!("Hello {} is {number:.prec$}", "x", prec = 5, number = 0.01);
|
460 | 460 | //! ```
|
461 | 461 | //!
|
462 |
| -//! All print the same thing: |
463 |
| -//! |
464 |
| -//! ```text |
465 |
| -//! Hello x is 0.01000 |
466 |
| -//! ``` |
467 |
| -//! |
468 | 462 | //! While these:
|
469 | 463 | //!
|
470 | 464 | //! ```
|
|
0 commit comments