From db84fc140301fcc4317616f302c2812b06263632 Mon Sep 17 00:00:00 2001 From: M Farkas-Dyck Date: Thu, 26 May 2016 17:44:13 -0800 Subject: [PATCH] make core::str::next_code_point work on arbitrary iterator --- src/libcore/str/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 2c34caf63b846..32b81ab7f53a8 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -354,7 +354,7 @@ fn unwrap_or_0(opt: Option<&u8>) -> u8 { /// UTF-8-like encoding). #[unstable(feature = "str_internals", issue = "0")] #[inline] -pub fn next_code_point(bytes: &mut slice::Iter) -> Option { +pub fn next_code_point<'a, I: Iterator>(bytes: &mut I) -> Option { // Decode UTF-8 let x = match bytes.next() { None => return None, @@ -388,7 +388,8 @@ pub fn next_code_point(bytes: &mut slice::Iter) -> Option { /// Reads the last code point out of a byte iterator (assuming a /// UTF-8-like encoding). #[inline] -fn next_code_point_reverse(bytes: &mut slice::Iter) -> Option { +fn next_code_point_reverse<'a, + I: DoubleEndedIterator>(bytes: &mut I) -> Option { // Decode UTF-8 let w = match bytes.next_back() { None => return None,