Skip to content

Commit

Permalink
Reject '2' as a binary digit in internals of 'b' formatting
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
daboross committed Nov 29, 2017
1 parent 77ab3a1 commit 2c98378
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libcore/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ macro_rules! radix {
}
}

radix! { Binary, 2, "0b", x @ 0 ... 2 => b'0' + x }
radix! { Binary, 2, "0b", x @ 0 ... 1 => b'0' + x }
radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x }
radix! { Decimal, 10, "", x @ 0 ... 9 => b'0' + x }
radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
Expand Down

0 comments on commit 2c98378

Please sign in to comment.