diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2015-01-27 14:09:18 +0100 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2015-02-20 00:57:38 +0100 |
| commit | f9ef8cd55512842f2481aac6332dbfb92df58c52 (patch) | |
| tree | ca3ad91d959a4cc95780dfed26f40337ffc72014 /src/libcore/char.rs | |
| parent | 13ea9062a918e3e60d82186135610a575bf92394 (diff) | |
| download | rust-f9ef8cd55512842f2481aac6332dbfb92df58c52.tar.gz rust-f9ef8cd55512842f2481aac6332dbfb92df58c52.zip | |
Refactored code into Searcher traits with naive implementations
Made the family of Split iterators use the Pattern API Renamed the Matcher traits into Searcher
Diffstat (limited to 'src/libcore/char.rs')
| -rw-r--r-- | src/libcore/char.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/libcore/char.rs b/src/libcore/char.rs index c45fac1bc94..8e27ae1cea9 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -22,13 +22,13 @@ use option::Option; use slice::SliceExt; // UTF-8 ranges and tags for encoding characters -static TAG_CONT: u8 = 0b1000_0000u8; -static TAG_TWO_B: u8 = 0b1100_0000u8; -static TAG_THREE_B: u8 = 0b1110_0000u8; -static TAG_FOUR_B: u8 = 0b1111_0000u8; -static MAX_ONE_B: u32 = 0x80u32; -static MAX_TWO_B: u32 = 0x800u32; -static MAX_THREE_B: u32 = 0x10000u32; +const TAG_CONT: u8 = 0b1000_0000u8; +const TAG_TWO_B: u8 = 0b1100_0000u8; +const TAG_THREE_B: u8 = 0b1110_0000u8; +const TAG_FOUR_B: u8 = 0b1111_0000u8; +const MAX_ONE_B: u32 = 0x80u32; +const MAX_TWO_B: u32 = 0x800u32; +const MAX_THREE_B: u32 = 0x10000u32; /* Lu Uppercase_Letter an uppercase letter @@ -398,11 +398,14 @@ impl CharExt for char { #[stable(feature = "rust1", since = "1.0.0")] fn len_utf8(self) -> usize { let code = self as u32; - match () { - _ if code < MAX_ONE_B => 1, - _ if code < MAX_TWO_B => 2, - _ if code < MAX_THREE_B => 3, - _ => 4, + if code < MAX_ONE_B { + 1 + } else if code < MAX_TWO_B { + 2 + } else if code < MAX_THREE_B { + 3 + } else { + 4 } } |
