Skip to content

Commit

Permalink
add: zero padding example
Browse files Browse the repository at this point in the history
  • Loading branch information
brnt-toast committed Apr 30, 2023
1 parent 3eb8bd2 commit aafbd5b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/hello/print.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ fn main() {
println!("{number:>5}", number=1);
// You can pad numbers with extra zeroes,
println!("{number:0>5}", number=1); // 00001
// and left-adjust by flipping the sign. This will output "10000".
println!("{number:0<5}", number=1);
println!("{number:0<5}", number=1); // 10000
// You can use named arguments in the format specifier by appending a `$`.
println!("{number:0>width$}", number=1, width=5);
Expand All @@ -62,7 +63,7 @@ fn main() {
// This will not compile because `Structure` does not implement
// fmt::Display.
//println!("This struct `{}` won't print...", Structure(3));
// println!("This struct `{}` won't print...", Structure(3));
// TODO ^ Try uncommenting this line
// For Rust 1.58 and above, you can directly capture the argument from a
Expand Down

0 comments on commit aafbd5b

Please sign in to comment.