about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Ross <daboross@daboross.net>2017-11-28 21:35:18 -0800
committerGitHub <noreply@github.com>2017-11-28 21:35:18 -0800
commit2c98378ace8d9d406c9701844a7e556def6f7cbc (patch)
treed7663afac8044e4dfbd69933b38496822e717072
parent77ab3a1d5ff69c0cb3eb85a75ef734eaf7429f1b (diff)
downloadrust-2c98378ace8d9d406c9701844a7e556def6f7cbc.tar.gz
rust-2c98378ace8d9d406c9701844a7e556def6f7cbc.zip
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.
-rw-r--r--src/libcore/fmt/num.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs
index c8218172583..ee989854a37 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,