Skip to content

Commit abbccac

Browse files
authored
Merge pull request #1501 from taufik-rama/master
Added new Rust 1.58 direct format args
2 parents 8186f0d + 4504870 commit abbccac

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/hello/print.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ fn main() {
5454
// handling. This will not work.
5555
println!("This struct `{}` won't print...", Structure(3));
5656
// FIXME ^ Comment out this line.
57+
58+
// For Rust 1.58 and above, you can directly capture the argument from
59+
// surrounding variable. Just like the above, this will output
60+
// " 1". 5 white spaces and a "1".
61+
let number: f64 = 1.0;
62+
let width: usize = 6;
63+
println!("{number:>width$}");
5764
}
5865
```
5966

0 commit comments

Comments
 (0)