From 3024c1434a667425d30e4b0785857381323712aa Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 8 Dec 2017 17:32:04 -0800 Subject: Use Try syntax for Option in place of macros or match --- src/libcore/str/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/libcore') 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>(bytes: &mut I) -> Option { // 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] -- cgit 1.4.1-3-g733a5