File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 395395//! `0`.
396396//!
397397//! The value for the width can also be provided as a `usize` in the list of
398- //! parameters by using the `2$` syntax indicating that the second argument is a
399- //! `usize` specifying the width.
398+ //! parameters by using the dollar syntax indicating that the second argument is
399+ //! a `usize` specifying the width, for example:
400+ //!
401+ //! ```
402+ //! // All of these print "Hello x !"
403+ //! println!("Hello {:5}!", "x");
404+ //! println!("Hello {:1$}!", "x", 5);
405+ //! println!("Hello {1:0$}!", 5, "x");
406+ //! ```
407+ //!
408+ //! Referring to an argument with the dollar syntax does not affect the "next
409+ //! argument" counter, so it's usually a good idea to refer to all arguments by
410+ //! their position explicitly.
400411//!
401412//! ## Precision
402413//!
You can’t perform that action at this time.
0 commit comments