Skip to content

Commit db84fc1

Browse files
author
M Farkas-Dyck
committed
make core::str::next_code_point work on arbitrary iterator
1 parent 8393d99 commit db84fc1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcore/str/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ fn unwrap_or_0(opt: Option<&u8>) -> u8 {
354354
/// UTF-8-like encoding).
355355
#[unstable(feature = "str_internals", issue = "0")]
356356
#[inline]
357-
pub fn next_code_point(bytes: &mut slice::Iter<u8>) -> Option<u32> {
357+
pub fn next_code_point<'a, I: Iterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> {
358358
// Decode UTF-8
359359
let x = match bytes.next() {
360360
None => return None,
@@ -388,7 +388,8 @@ pub fn next_code_point(bytes: &mut slice::Iter<u8>) -> Option<u32> {
388388
/// Reads the last code point out of a byte iterator (assuming a
389389
/// UTF-8-like encoding).
390390
#[inline]
391-
fn next_code_point_reverse(bytes: &mut slice::Iter<u8>) -> Option<u32> {
391+
fn next_code_point_reverse<'a,
392+
I: DoubleEndedIterator<Item = &'a u8>>(bytes: &mut I) -> Option<u32> {
392393
// Decode UTF-8
393394
let w = match bytes.next_back() {
394395
None => return None,

0 commit comments

Comments
 (0)