about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-06-01 12:57:41 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-06-01 12:57:41 +0530
commit67e158fc4c949a3664f2e60b13077cbbc7b9d78f (patch)
tree30a2bb377b7ef9bb325595d8b04665a840fc0fd6 /src/libcore
parent7694e18d4351b046ff8201af178bb82f9cbec34a (diff)
parentdb84fc140301fcc4317616f302c2812b06263632 (diff)
downloadrust-67e158fc4c949a3664f2e60b13077cbbc7b9d78f.tar.gz
rust-67e158fc4c949a3664f2e60b13077cbbc7b9d78f.zip
Rollup merge of #33896 - strake:next_code_point, r=aturon
make core::str::next_code_point work on arbitrary iterator
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/str/mod.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index 2c34caf63b8..32b81ab7f53 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<u8>) -> Option<u32> {
+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,
@@ -388,7 +388,8 @@ pub fn next_code_point(bytes: &mut slice::Iter<u8>) -> Option<u32> {
 /// 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<u8>) -> Option<u32> {
+fn next_code_point_reverse<'a,
+                           I: DoubleEndedIterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> {
     // Decode UTF-8
     let w = match bytes.next_back() {
         None => return None,