Skip to content

Commit

Permalink
Added new Rust 1.58 direct format args
Browse files Browse the repository at this point in the history
  • Loading branch information
taufik-rama committed Feb 5, 2022
1 parent 18c0055 commit 4504870
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/hello/print.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ fn main() {
// handling. This will not work.
println!("This struct `{}` won't print...", Structure(3));
// FIXME ^ Comment out this line.
// For Rust 1.58 and above, you can directly capture the argument from
// surrounding variable. Just like the above, this will output
// " 1". 5 white spaces and a "1".
let number: f64 = 1.0;
let width: usize = 6;
println!("{number:>width$}");
}
```

Expand Down

0 comments on commit 4504870

Please sign in to comment.