Skip to content

Commit 59b6263

Browse files
authored
Unrolled build for rust-lang#116326
Rollup merge of rust-lang#116326 - Colonial-Dev:issue-116165-fix, r=joshtriplett Correct misleading std::fmt::Binary example (rust-lang#116165) Nothing too crazy... - Add two to the width specifier (so all 32 bits are correctly displayed) - Pad out the compared string so the assert passes - Add `// Note` comment highlighting the need for the extra width when using the `#` flag. The exact contents (and placement?) of the note are, of course, highly bikesheddable.
2 parents b0889cb + f2ecf7c commit 59b6263

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/core/src/fmt/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,10 @@ pub trait Octal {
791791
/// assert_eq!(format!("l as binary is: {l:b}"), "l as binary is: 1101011");
792792
///
793793
/// assert_eq!(
794-
/// format!("l as binary is: {l:#032b}"),
795-
/// "l as binary is: 0b000000000000000000000001101011"
794+
/// // Note that the `0b` prefix added by `#` is included in the total width, so we
795+
/// // need to add two to correctly display all 32 bits.
796+
/// format!("l as binary is: {l:#034b}"),
797+
/// "l as binary is: 0b00000000000000000000000001101011"
796798
/// );
797799
/// ```
798800
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)