Skip to content

Commit 8ee9528

Browse files
authored
Merge pull request #1706 from brnt-toast/master
add: zero padding example
2 parents 3eb8bd2 + aafbd5b commit 8ee9528

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/hello/print.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ fn main() {
4444
println!("{number:>5}", number=1);
4545
4646
// You can pad numbers with extra zeroes,
47+
println!("{number:0>5}", number=1); // 00001
4748
// and left-adjust by flipping the sign. This will output "10000".
48-
println!("{number:0<5}", number=1);
49+
println!("{number:0<5}", number=1); // 10000
4950
5051
// You can use named arguments in the format specifier by appending a `$`.
5152
println!("{number:0>width$}", number=1, width=5);
@@ -62,7 +63,7 @@ fn main() {
6263
6364
// This will not compile because `Structure` does not implement
6465
// fmt::Display.
65-
//println!("This struct `{}` won't print...", Structure(3));
66+
// println!("This struct `{}` won't print...", Structure(3));
6667
// TODO ^ Try uncommenting this line
6768
6869
// For Rust 1.58 and above, you can directly capture the argument from a

0 commit comments

Comments
 (0)