|
85 | 85 | //! format!("{a} {c} {b}", a="a", b='b', c=3); // => "a 3 b"
|
86 | 86 | //! ```
|
87 | 87 | //!
|
88 |
| -//! It is illegal to put positional parameters (those without names) after |
89 |
| -//! arguments which have names. Like with positional parameters, it is illegal |
90 |
| -//! to provide named parameters that are unused by the format string. |
| 88 | +//! It is not valid to put positional parameters (those without names) after |
| 89 | +//! arguments which have names. Like with positional parameters, it is not |
| 90 | +//! valid to provide named parameters that are unused by the format string. |
91 | 91 | //!
|
92 | 92 | //! ## Argument types
|
93 | 93 | //!
|
|
103 | 103 | //! hexadecimal as well as an
|
104 | 104 | //! octal.
|
105 | 105 | //!
|
106 |
| -//! There are various parameters which do require a particular type, however. Namely, the `{:.*}` |
107 |
| -//! syntax, which sets the number of numbers after the decimal in floating-point types: |
| 106 | +//! There are various parameters which do require a particular type, however. |
| 107 | +//! Namely, the `{:.*}` syntax, which sets the number of numbers after the |
| 108 | +//! decimal in floating-point types: |
108 | 109 | //!
|
109 | 110 | //! ```
|
110 | 111 | //! let formatted_number = format!("{:.*}", 2, 1.234567);
|
111 | 112 | //!
|
112 | 113 | //! assert_eq!("1.23", formatted_number)
|
113 | 114 | //! ```
|
114 | 115 | //!
|
115 |
| -//! If this syntax is used, then the number of characters to print precedes the actual object being |
116 |
| -//! formatted, and the number of characters must have the type `usize`. Although a `usize` can be |
117 |
| -//! printed with `{}`, it is illegal to reference an argument as such. For example this is another |
118 |
| -//! invalid format string: |
| 116 | +//! If this syntax is used, then the number of characters to print precedes the |
| 117 | +//! actual object being formatted, and the number of characters must have the |
| 118 | +//! type `usize`. Although a `usize` can be printed with `{}`, it is invalid to |
| 119 | +//! reference an argument as such. For example this is another invalid format |
| 120 | +//! string: |
119 | 121 | //!
|
120 | 122 | //! ```text
|
121 | 123 | //! {:.*} {0}
|
|
0 commit comments