diff options
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/ascii.rs | 4 | ||||
| -rw-r--r-- | src/libcore/char/decode.rs | 18 | ||||
| -rw-r--r-- | src/libcore/char/methods.rs | 18 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 14 | ||||
| -rw-r--r-- | src/libcore/slice/mod.rs | 6 | ||||
| -rw-r--r-- | src/libcore/str/lossy.rs | 14 | ||||
| -rw-r--r-- | src/libcore/str/mod.rs | 14 | ||||
| -rw-r--r-- | src/libcore/tests/slice.rs | 4 |
8 files changed, 46 insertions, 46 deletions
diff --git a/src/libcore/ascii.rs b/src/libcore/ascii.rs index e6b0569281f..6ee91e0b22f 100644 --- a/src/libcore/ascii.rs +++ b/src/libcore/ascii.rs @@ -108,7 +108,7 @@ pub fn escape_default(c: u8) -> EscapeDefault { b'\\' => ([b'\\', b'\\', 0, 0], 2), b'\'' => ([b'\\', b'\'', 0, 0], 2), b'"' => ([b'\\', b'"', 0, 0], 2), - b'\x20' ... b'\x7e' => ([c, 0, 0, 0], 1), + b'\x20' ..= b'\x7e' => ([c, 0, 0, 0], 1), _ => ([b'\\', b'x', hexify(c >> 4), hexify(c & 0xf)], 4), }; @@ -116,7 +116,7 @@ pub fn escape_default(c: u8) -> EscapeDefault { fn hexify(b: u8) -> u8 { match b { - 0 ... 9 => b'0' + b, + 0 ..= 9 => b'0' + b, _ => b'a' + b - 10, } } diff --git a/src/libcore/char/decode.rs b/src/libcore/char/decode.rs index 45a73191db2..0b8dce19dff 100644 --- a/src/libcore/char/decode.rs +++ b/src/libcore/char/decode.rs @@ -64,7 +64,7 @@ impl<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> { } } macro_rules! continuation_byte { - () => { continuation_byte!(0x80...0xBF) }; + () => { continuation_byte!(0x80..=0xBF) }; ($range: pat) => { match self.0.peek() { Some(&byte @ $range) => { @@ -77,35 +77,35 @@ impl<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> { } match first_byte { - 0x00...0x7F => { + 0x00..=0x7F => { first_byte!(0b1111_1111); } - 0xC2...0xDF => { + 0xC2..=0xDF => { first_byte!(0b0001_1111); continuation_byte!(); } 0xE0 => { first_byte!(0b0000_1111); - continuation_byte!(0xA0...0xBF); // 0x80...0x9F here are overlong + continuation_byte!(0xA0..=0xBF); // 0x80..=0x9F here are overlong continuation_byte!(); } - 0xE1...0xEC | 0xEE...0xEF => { + 0xE1..=0xEC | 0xEE..=0xEF => { first_byte!(0b0000_1111); continuation_byte!(); continuation_byte!(); } 0xED => { first_byte!(0b0000_1111); - continuation_byte!(0x80...0x9F); // 0xA0..0xBF here are surrogates + continuation_byte!(0x80..=0x9F); // 0xA0..0xBF here are surrogates continuation_byte!(); } 0xF0 => { first_byte!(0b0000_0111); - continuation_byte!(0x90...0xBF); // 0x80..0x8F here are overlong + continuation_byte!(0x90..=0xBF); // 0x80..0x8F here are overlong continuation_byte!(); continuation_byte!(); } - 0xF1...0xF3 => { + 0xF1..=0xF3 => { first_byte!(0b0000_0111); continuation_byte!(); continuation_byte!(); @@ -113,7 +113,7 @@ impl<I: Iterator<Item = u8>> Iterator for DecodeUtf8<I> { } 0xF4 => { first_byte!(0b0000_0111); - continuation_byte!(0x80...0x8F); // 0x90..0xBF here are beyond char::MAX + continuation_byte!(0x80..=0x8F); // 0x90..0xBF here are beyond char::MAX continuation_byte!(); continuation_byte!(); } diff --git a/src/libcore/char/methods.rs b/src/libcore/char/methods.rs index f6b201fe06d..eee78de9036 100644 --- a/src/libcore/char/methods.rs +++ b/src/libcore/char/methods.rs @@ -125,9 +125,9 @@ impl char { panic!("to_digit: radix is too high (maximum 36)"); } let val = match self { - '0' ... '9' => self as u32 - '0' as u32, - 'a' ... 'z' => self as u32 - 'a' as u32 + 10, - 'A' ... 'Z' => self as u32 - 'A' as u32 + 10, + '0' ..= '9' => self as u32 - '0' as u32, + 'a' ..= 'z' => self as u32 - 'a' as u32 + 10, + 'A' ..= 'Z' => self as u32 - 'A' as u32 + 10, _ => return None, }; if val < radix { Some(val) } @@ -305,7 +305,7 @@ impl char { '\r' => EscapeDefaultState::Backslash('r'), '\n' => EscapeDefaultState::Backslash('n'), '\\' | '\'' | '"' => EscapeDefaultState::Backslash(self), - '\x20' ... '\x7e' => EscapeDefaultState::Char(self), + '\x20' ..= '\x7e' => EscapeDefaultState::Char(self), _ => EscapeDefaultState::Unicode(self.escape_unicode()) }; EscapeDefault { state: init_state } @@ -543,7 +543,7 @@ impl char { #[inline] pub fn is_alphabetic(self) -> bool { match self { - 'a'...'z' | 'A'...'Z' => true, + 'a'..='z' | 'A'..='Z' => true, c if c > '\x7f' => derived_property::Alphabetic(c), _ => false, } @@ -599,7 +599,7 @@ impl char { #[inline] pub fn is_lowercase(self) -> bool { match self { - 'a'...'z' => true, + 'a'..='z' => true, c if c > '\x7f' => derived_property::Lowercase(c), _ => false, } @@ -627,7 +627,7 @@ impl char { #[inline] pub fn is_uppercase(self) -> bool { match self { - 'A'...'Z' => true, + 'A'..='Z' => true, c if c > '\x7f' => derived_property::Uppercase(c), _ => false, } @@ -654,7 +654,7 @@ impl char { #[inline] pub fn is_whitespace(self) -> bool { match self { - ' ' | '\x09'...'\x0d' => true, + ' ' | '\x09'..='\x0d' => true, c if c > '\x7f' => property::White_Space(c), _ => false, } @@ -737,7 +737,7 @@ impl char { #[inline] pub fn is_numeric(self) -> bool { match self { - '0'...'9' => true, + '0'..='9' => true, c if c > '\x7f' => general_category::N(c), _ => false, } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 4451ab445cc..51391fa50d5 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -121,19 +121,19 @@ macro_rules! radix { fn digit(x: u8) -> u8 { match x { $($x => $conv,)+ - x => panic!("number not in the range 0..{}: {}", Self::BASE - 1, x), + x => panic!("number not in the range 0..={}: {}", Self::BASE - 1, x), } } } } } -radix! { Binary, 2, "0b", x @ 0 ... 1 => b'0' + x } -radix! { Octal, 8, "0o", x @ 0 ... 7 => b'0' + x } -radix! { LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'a' + (x - 10) } -radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, - x @ 10 ... 15 => b'A' + (x - 10) } +radix! { Binary, 2, "0b", x @ 0 ..= 1 => b'0' + x } +radix! { Octal, 8, "0o", x @ 0 ..= 7 => b'0' + x } +radix! { LowerHex, 16, "0x", x @ 0 ..= 9 => b'0' + x, + x @ 10 ..= 15 => b'a' + (x - 10) } +radix! { UpperHex, 16, "0x", x @ 0 ..= 9 => b'0' + x, + x @ 10 ..= 15 => b'A' + (x - 10) } macro_rules! int_base { ($Trait:ident for $T:ident as $U:ident -> $Radix:ident) => { diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index 6f4c130d8f3..e74e527927d 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1230,7 +1230,7 @@ impl<T> [T] { /// assert_eq!(s.binary_search(&4), Err(7)); /// assert_eq!(s.binary_search(&100), Err(13)); /// let r = s.binary_search(&1); - /// assert!(match r { Ok(1...4) => true, _ => false, }); + /// assert!(match r { Ok(1..=4) => true, _ => false, }); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn binary_search(&self, x: &T) -> Result<usize, usize> @@ -1268,7 +1268,7 @@ impl<T> [T] { /// assert_eq!(s.binary_search_by(|probe| probe.cmp(&seek)), Err(13)); /// let seek = 1; /// let r = s.binary_search_by(|probe| probe.cmp(&seek)); - /// assert!(match r { Ok(1...4) => true, _ => false, }); + /// assert!(match r { Ok(1..=4) => true, _ => false, }); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -1325,7 +1325,7 @@ impl<T> [T] { /// assert_eq!(s.binary_search_by_key(&4, |&(a,b)| b), Err(7)); /// assert_eq!(s.binary_search_by_key(&100, |&(a,b)| b), Err(13)); /// let r = s.binary_search_by_key(&1, |&(a,b)| b); - /// assert!(match r { Ok(1...4) => true, _ => false, }); + /// assert!(match r { Ok(1..=4) => true, _ => false, }); /// ``` #[stable(feature = "slice_binary_search_by_key", since = "1.10.0")] #[inline] diff --git a/src/libcore/str/lossy.rs b/src/libcore/str/lossy.rs index 30b7267da7c..5cfb36d3b19 100644 --- a/src/libcore/str/lossy.rs +++ b/src/libcore/str/lossy.rs @@ -101,10 +101,10 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> { } 3 => { match (byte, safe_get(self.source, i)) { - (0xE0, 0xA0 ... 0xBF) => (), - (0xE1 ... 0xEC, 0x80 ... 0xBF) => (), - (0xED, 0x80 ... 0x9F) => (), - (0xEE ... 0xEF, 0x80 ... 0xBF) => (), + (0xE0, 0xA0 ..= 0xBF) => (), + (0xE1 ..= 0xEC, 0x80 ..= 0xBF) => (), + (0xED, 0x80 ..= 0x9F) => (), + (0xEE ..= 0xEF, 0x80 ..= 0xBF) => (), _ => { error!(); } @@ -117,9 +117,9 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> { } 4 => { match (byte, safe_get(self.source, i)) { - (0xF0, 0x90 ... 0xBF) => (), - (0xF1 ... 0xF3, 0x80 ... 0xBF) => (), - (0xF4, 0x80 ... 0x8F) => (), + (0xF0, 0x90 ..= 0xBF) => (), + (0xF1 ..= 0xF3, 0x80 ..= 0xBF) => (), + (0xF4, 0x80 ..= 0x8F) => (), _ => { error!(); } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 5e1a9c25a21..42fb1bc238b 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1484,10 +1484,10 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> { }, 3 => { match (first, next!()) { - (0xE0 , 0xA0 ... 0xBF) | - (0xE1 ... 0xEC, 0x80 ... 0xBF) | - (0xED , 0x80 ... 0x9F) | - (0xEE ... 0xEF, 0x80 ... 0xBF) => {} + (0xE0 , 0xA0 ..= 0xBF) | + (0xE1 ..= 0xEC, 0x80 ..= 0xBF) | + (0xED , 0x80 ..= 0x9F) | + (0xEE ..= 0xEF, 0x80 ..= 0xBF) => {} _ => err!(Some(1)) } if next!() & !CONT_MASK != TAG_CONT_U8 { @@ -1496,9 +1496,9 @@ fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> { } 4 => { match (first, next!()) { - (0xF0 , 0x90 ... 0xBF) | - (0xF1 ... 0xF3, 0x80 ... 0xBF) | - (0xF4 , 0x80 ... 0x8F) => {} + (0xF0 , 0x90 ..= 0xBF) | + (0xF1 ..= 0xF3, 0x80 ..= 0xBF) | + (0xF4 , 0x80 ..= 0x8F) => {} _ => err!(Some(1)) } if next!() & !CONT_MASK != TAG_CONT_U8 { diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index fcd79222e16..7981567067d 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -60,8 +60,8 @@ fn test_binary_search() { assert_eq!(b.binary_search(&0), Err(0)); assert_eq!(b.binary_search(&1), Ok(0)); assert_eq!(b.binary_search(&2), Err(1)); - assert!(match b.binary_search(&3) { Ok(1...3) => true, _ => false }); - assert!(match b.binary_search(&3) { Ok(1...3) => true, _ => false }); + assert!(match b.binary_search(&3) { Ok(1..=3) => true, _ => false }); + assert!(match b.binary_search(&3) { Ok(1..=3) => true, _ => false }); assert_eq!(b.binary_search(&4), Err(4)); assert_eq!(b.binary_search(&5), Err(4)); assert_eq!(b.binary_search(&6), Err(4)); |
