diff options
| author | bors <bors@rust-lang.org> | 2014-10-01 03:17:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-01 03:17:24 +0000 |
| commit | 2f15dcd4d3865f9cc466637027eb02d5607b2bb7 (patch) | |
| tree | 1a4d8526c45a53753c612bcbb6d283928c927cbc /src/libcore | |
| parent | 57a05cf49b3149427e3fe190c07f8343a29ad86c (diff) | |
| parent | 416144b8279fbffceacea6d0fd90e0fd1f8ce53d (diff) | |
auto merge of #17584 : pcwalton/rust/range-patterns-dotdotdot, r=nick29581
This breaks code that looks like:
match foo {
1..3 => { ... }
}
Instead, write:
match foo {
1...3 => { ... }
}
Closes #17295.
r? @nick29581
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/char.rs | 10 | ||||
| -rw-r--r-- | src/libcore/fmt/num.rs | 16 | ||||
| -rw-r--r-- | src/libcore/str.rs | 14 |
3 files changed, 20 insertions, 20 deletions
diff --git a/src/libcore/char.rs b/src/libcore/char.rs index c870f1b8f70..1e87d11d373 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -123,9 +123,9 @@ pub fn to_digit(c: char, radix: uint) -> Option<uint> { fail!("to_digit: radix is too high (maximum 36)"); } let val = match c { - '0' .. '9' => c as uint - ('0' as uint), - 'a' .. 'z' => c as uint + 10u - ('a' as uint), - 'A' .. 'Z' => c as uint + 10u - ('A' as uint), + '0' ... '9' => c as uint - ('0' as uint), + 'a' ... 'z' => c as uint + 10u - ('a' as uint), + 'A' ... 'Z' => c as uint + 10u - ('A' as uint), _ => return None, }; if val < radix { Some(val) } @@ -184,7 +184,7 @@ pub fn escape_unicode(c: char, f: |char|) { let offset = offset as uint; unsafe { match ((c as i32) >> offset) & 0xf { - i @ 0 .. 9 => { f(transmute('0' as i32 + i)); } + i @ 0 ... 9 => { f(transmute('0' as i32 + i)); } i => { f(transmute('a' as i32 + (i - 10))); } } } @@ -211,7 +211,7 @@ pub fn escape_default(c: char, f: |char|) { '\\' => { f('\\'); f('\\'); } '\'' => { f('\\'); f('\''); } '"' => { f('\\'); f('"'); } - '\x20' .. '\x7e' => { f(c); } + '\x20' ... '\x7e' => { f(c); } _ => c.escape_unicode(f), } } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index eb8d684fe50..afcd0d1d645 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -99,13 +99,13 @@ macro_rules! radix { } } -radix!(Binary, 2, "0b", x @ 0 .. 2 => 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, - 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 ... 2 => 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, + x @ 10 ... 15 => b'a' + (x - 10)) +radix!(UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, + x @ 10 ... 15 => b'A' + (x - 10)) /// A radix with in the range of `2..36`. #[deriving(Clone, PartialEq)] @@ -124,7 +124,7 @@ impl GenericRadix for Radix { fn base(&self) -> u8 { self.base } fn digit(&self, x: u8) -> u8 { match x { - x @ 0 ..9 => b'0' + x, + x @ 0 ... 9 => b'0' + x, x if x < self.base() => b'a' + (x - 10), x => fail!("number not in the range 0..{}: {}", self.base() - 1, x), } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 343b8e0b64b..fd7c63a6b32 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -843,18 +843,18 @@ fn run_utf8_validation_iterator(iter: &mut slice::Items<u8>) -> bool { 2 => if second & !CONT_MASK != TAG_CONT_U8 {err!()}, 3 => { match (first, second, next!() & !CONT_MASK) { - (0xE0 , 0xA0 .. 0xBF, TAG_CONT_U8) | - (0xE1 .. 0xEC, 0x80 .. 0xBF, TAG_CONT_U8) | - (0xED , 0x80 .. 0x9F, TAG_CONT_U8) | - (0xEE .. 0xEF, 0x80 .. 0xBF, TAG_CONT_U8) => {} + (0xE0 , 0xA0 ... 0xBF, TAG_CONT_U8) | + (0xE1 ... 0xEC, 0x80 ... 0xBF, TAG_CONT_U8) | + (0xED , 0x80 ... 0x9F, TAG_CONT_U8) | + (0xEE ... 0xEF, 0x80 ... 0xBF, TAG_CONT_U8) => {} _ => err!() } } 4 => { match (first, second, next!() & !CONT_MASK, next!() & !CONT_MASK) { - (0xF0 , 0x90 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) | - (0xF1 .. 0xF3, 0x80 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) | - (0xF4 , 0x80 .. 0x8F, TAG_CONT_U8, TAG_CONT_U8) => {} + (0xF0 , 0x90 ... 0xBF, TAG_CONT_U8, TAG_CONT_U8) | + (0xF1 ... 0xF3, 0x80 ... 0xBF, TAG_CONT_U8, TAG_CONT_U8) | + (0xF4 , 0x80 ... 0x8F, TAG_CONT_U8, TAG_CONT_U8) => {} _ => err!() } } |
