From 8c59ec048831c913110a0aa385b1cb6f29de28d7 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 1 Jan 2015 23:19:06 -0500 Subject: [PATCH] unicode: fix fallout --- src/libunicode/lib.rs | 1 + src/libunicode/u_str.rs | 28 +++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/libunicode/lib.rs b/src/libunicode/lib.rs index d33362ec232..eabe044ce3b 100644 --- a/src/libunicode/lib.rs +++ b/src/libunicode/lib.rs @@ -29,6 +29,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![no_std] #![feature(globs, macro_rules, slicing_syntax, unboxed_closures)] +#![feature(associated_types)] extern crate core; diff --git a/src/libunicode/u_str.rs b/src/libunicode/u_str.rs index e17bf025cba..8ec90acb711 100644 --- a/src/libunicode/u_str.rs +++ b/src/libunicode/u_str.rs @@ -105,7 +105,9 @@ pub struct GraphemeIndices<'a> { iter: Graphemes<'a>, } -impl<'a> Iterator<(uint, &'a str)> for GraphemeIndices<'a> { +impl<'a> Iterator for GraphemeIndices<'a> { + type Item = (uint, &'a str); + #[inline] fn next(&mut self) -> Option<(uint, &'a str)> { self.iter.next().map(|s| (s.as_ptr() as uint - self.start_offset, s)) @@ -117,7 +119,7 @@ fn size_hint(&self) -> (uint, Option) { } } -impl<'a> DoubleEndedIterator<(uint, &'a str)> for GraphemeIndices<'a> { +impl<'a> DoubleEndedIterator for GraphemeIndices<'a> { #[inline] fn next_back(&mut self) -> Option<(uint, &'a str)> { self.iter.next_back().map(|s| (s.as_ptr() as uint - self.start_offset, s)) @@ -145,7 +147,9 @@ enum GraphemeState { Regional, } -impl<'a> Iterator<&'a str> for Graphemes<'a> { +impl<'a> Iterator for Graphemes<'a> { + type Item = &'a str; + #[inline] fn size_hint(&self) -> (uint, Option) { let slen = self.string.len(); @@ -251,7 +255,7 @@ fn next(&mut self) -> Option<&'a str> { } } -impl<'a> DoubleEndedIterator<&'a str> for Graphemes<'a> { +impl<'a> DoubleEndedIterator for Graphemes<'a> { #[inline] fn next_back(&mut self) -> Option<&'a str> { use tables::grapheme as gr; @@ -428,7 +432,9 @@ pub fn to_char_lossy(&self) -> char { } } -impl<'a> Iterator for Utf16Items<'a> { +impl<'a> Iterator for Utf16Items<'a> { + type Item = Utf16Item; + fn next(&mut self) -> Option { let u = match self.iter.next() { Some(u) => *u, @@ -505,12 +511,14 @@ pub struct Utf16Encoder { impl Utf16Encoder { /// Create an UTF-16 encoder from any `char` iterator. - pub fn new(chars: I) -> Utf16Encoder where I: Iterator { + pub fn new(chars: I) -> Utf16Encoder where I: Iterator { Utf16Encoder { chars: chars, extra: 0 } } } -impl Iterator for Utf16Encoder where I: Iterator { +impl Iterator for Utf16Encoder where I: Iterator { + type Item = u16; + #[inline] fn next(&mut self) -> Option { if self.extra != 0 { @@ -537,9 +545,11 @@ fn size_hint(&self) -> (uint, Option) { } } -impl<'a> Iterator<&'a str> for Words<'a> { +impl<'a> Iterator for Words<'a> { + type Item = &'a str; + fn next(&mut self) -> Option<&'a str> { self.inner.next() } } -impl<'a> DoubleEndedIterator<&'a str> for Words<'a> { +impl<'a> DoubleEndedIterator for Words<'a> { fn next_back(&mut self) -> Option<&'a str> { self.inner.next_back() } } -- 2.44.0