1
Fork 0

migrate codebase to ..= inclusive range patterns

These were stabilized in March 2018's #47813, and are the Preferred Way
to Do It going forward (q.v. #51043).
This commit is contained in:
Zack M. Davis 2018-05-28 19:42:11 -07:00
parent 764232cb2a
commit 057715557b
65 changed files with 217 additions and 218 deletions

View file

@ -1557,14 +1557,14 @@ impl<T: Iterator<Item=char>> Parser<T> {
self.bump();
// A leading '0' must be the only digit before the decimal point.
if let '0' ... '9' = self.ch_or_null() {
if let '0' ..= '9' = self.ch_or_null() {
return self.error(InvalidNumber)
}
},
'1' ... '9' => {
'1' ..= '9' => {
while !self.eof() {
match self.ch_or_null() {
c @ '0' ... '9' => {
c @ '0' ..= '9' => {
accum = accum.wrapping_mul(10);
accum = accum.wrapping_add((c as u64) - ('0' as u64));
@ -1588,14 +1588,14 @@ impl<T: Iterator<Item=char>> Parser<T> {
// Make sure a digit follows the decimal place.
match self.ch_or_null() {
'0' ... '9' => (),
'0' ..= '9' => (),
_ => return self.error(InvalidNumber)
}
let mut dec = 1.0;
while !self.eof() {
match self.ch_or_null() {
c @ '0' ... '9' => {
c @ '0' ..= '9' => {
dec /= 10.0;
res += (((c as isize) - ('0' as isize)) as f64) * dec;
self.bump();
@ -1622,12 +1622,12 @@ impl<T: Iterator<Item=char>> Parser<T> {
// Make sure a digit follows the exponent place.
match self.ch_or_null() {
'0' ... '9' => (),
'0' ..= '9' => (),
_ => return self.error(InvalidNumber)
}
while !self.eof() {
match self.ch_or_null() {
c @ '0' ... '9' => {
c @ '0' ..= '9' => {
exp *= 10;
exp += (c as usize) - ('0' as usize);
@ -1653,7 +1653,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
while i < 4 && !self.eof() {
self.bump();
n = match self.ch_or_null() {
c @ '0' ... '9' => n * 16 + ((c as u16) - ('0' as u16)),
c @ '0' ..= '9' => n * 16 + ((c as u16) - ('0' as u16)),
'a' | 'A' => n * 16 + 10,
'b' | 'B' => n * 16 + 11,
'c' | 'C' => n * 16 + 12,
@ -1695,13 +1695,13 @@ impl<T: Iterator<Item=char>> Parser<T> {
'r' => res.push('\r'),
't' => res.push('\t'),
'u' => match self.decode_hex_escape()? {
0xDC00 ... 0xDFFF => {
0xDC00 ..= 0xDFFF => {
return self.error(LoneLeadingSurrogateInHexEscape)
}
// Non-BMP characters are encoded as a sequence of
// two hex escapes, representing UTF-16 surrogates.
n1 @ 0xD800 ... 0xDBFF => {
n1 @ 0xD800 ..= 0xDBFF => {
match (self.next_char(), self.next_char()) {
(Some('\\'), Some('u')) => (),
_ => return self.error(UnexpectedEndOfHexEscape),
@ -1928,7 +1928,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
'n' => { self.parse_ident("ull", NullValue) }
't' => { self.parse_ident("rue", BooleanValue(true)) }
'f' => { self.parse_ident("alse", BooleanValue(false)) }
'0' ... '9' | '-' => self.parse_number(),
'0' ..= '9' | '-' => self.parse_number(),
'"' => match self.parse_str() {
Ok(s) => StringValue(s),
Err(e) => Error(e),