Description
Location
https://doc.rust-lang.org/std/fmt/trait.Binary.html
Specifically the last assert in the Examples section:
assert_eq!( format!("l as binary is: {l:#032b}"), "l as binary is: 0b000000000000000000000001101011" );
Summary
This example shows how to format the binary representation of an i32 and was probably meant to display all 32 bits, but actually only displays 30 bits because the alternate flag #
adds the prefix 0b
to the representation, which is included in the total width of the padding (which is mentioned in passing here: https://doc.rust-lang.org/std/fmt/index.html#sign0 ).
I think it would be useful to mention in that example that the 0b
prefix is included in the total width, and I would also suggest changing the example to use {l:#034b}
as that is probably what the reader is expecting when displaying a padded i32,