Skip to content

Commit

Permalink
Rollup merge of rust-lang#33896 - strake:next_code_point, r=aturon
Browse files Browse the repository at this point in the history
make core::str::next_code_point work on arbitrary iterator
  • Loading branch information
Manishearth committed Jun 1, 2016
2 parents 7694e18 + db84fc1 commit 67e158f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libcore/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 67e158f

Please sign in to comment.