diff options
| author | bors <bors@rust-lang.org> | 2017-12-10 00:57:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-12-10 00:57:40 +0000 |
| commit | c89e206eedee079c4620eacbfb4e3bc6cf392fc8 (patch) | |
| tree | d362e737537921ce60a13c88139b708e63e29a01 /src/libcore | |
| parent | 8db163e53dab4f188a60bf24b4d6ebeb1ea5cab1 (diff) | |
| parent | 3024c1434a667425d30e4b0785857381323712aa (diff) | |
| download | rust-c89e206eedee079c4620eacbfb4e3bc6cf392fc8.tar.gz rust-c89e206eedee079c4620eacbfb4e3bc6cf392fc8.zip | |
Auto merge of #46602 - mbrubeck:try, r=kennytm
Replace option_try macros and match with ? operator None
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/str/mod.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index be5108238fc..1ca995cae6d 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -494,11 +494,10 @@ fn unwrap_or_0(opt: Option<&u8>) -> u8 { #[inline] pub fn next_code_point<'a, I: Iterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> { // Decode UTF-8 - let x = match bytes.next() { - None => return None, - Some(&next_byte) if next_byte < 128 => return Some(next_byte as u32), - Some(&next_byte) => next_byte, - }; + let x = *bytes.next()?; + if x < 128 { + return Some(x as u32) + } // Multibyte case follows // Decode from a byte combination out of: [[[x y] z] w] |
