From 2c98378ace8d9d406c9701844a7e556def6f7cbc Mon Sep 17 00:00:00 2001 From: David Ross Date: Tue, 28 Nov 2017 21:35:18 -0800 Subject: [PATCH] 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. --- src/libcore/fmt/num.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index c8218172583d6..ee989854a3772 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -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,