Skip to content

Commit 2c98378

Browse files
authored
Reject '2' as a binary digit in internals of 'b' formatting
I don't believe the previous code `0 ... 2` would run into any real problems, but it seems confusing to read, given that '2' is never a valid binary digit. As far as I can tell this code is only ever called from within another private method in the trait which has logic to never hand it '2' anyways. I thought we could change this for clarity anyways.
1 parent 77ab3a1 commit 2c98378

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/fmt/num.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ macro_rules! radix {
134134
}
135135
}
136136

137-
radix! { Binary, 2, "0b", x @ 0 ... 2 => b'0' + x }
137+
radix! { Binary, 2, "0b", x @ 0 ... 1 => b'0' + x }
138138
radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x }
139139
radix! { Decimal, 10, "", x @ 0 ... 9 => b'0' + x }
140140
radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x,

0 commit comments

Comments
 (0)