about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/str/mod.rs9
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]