diff options
| author | James Haywood <jameshaywood@fastmail.com> | 2023-10-01 23:58:54 -0400 |
|---|---|---|
| committer | James Haywood <jameshaywood@fastmail.com> | 2023-10-01 23:58:54 -0400 |
| commit | f2ecf7c51114fe4b620334843eb4a6f6d3f6cbfd (patch) | |
| tree | 9d9a67e6fec49b16776e68f8a5d3ef4b4e735351 | |
| parent | e0d7ed1f453fb54578cc96dfea859b0e7be15016 (diff) | |
| download | rust-f2ecf7c51114fe4b620334843eb4a6f6d3f6cbfd.tar.gz rust-f2ecf7c51114fe4b620334843eb4a6f6d3f6cbfd.zip | |
Correct misleading std::fmt::Binary example
| -rw-r--r-- | library/core/src/fmt/mod.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index fc91d1afc43..f7d3cda2fe9 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -791,8 +791,10 @@ pub trait Octal { /// assert_eq!(format!("l as binary is: {l:b}"), "l as binary is: 1101011"); /// /// assert_eq!( -/// format!("l as binary is: {l:#032b}"), -/// "l as binary is: 0b000000000000000000000001101011" +/// // Note that the `0b` prefix added by `#` is included in the total width, so we +/// // need to add two to correctly display all 32 bits. +/// format!("l as binary is: {l:#034b}"), +/// "l as binary is: 0b00000000000000000000000001101011" /// ); /// ``` #[stable(feature = "rust1", since = "1.0.0")] |
