diff options
Diffstat (limited to 'src/libstd/sys/common/wtf8.rs')
| -rw-r--r-- | src/libstd/sys/common/wtf8.rs | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index b610f6c370b..ca3ae1a7a34 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -31,8 +31,9 @@ use ascii::*; use borrow::Cow; use cmp; use fmt; -use hash::{Hash, Writer, Hasher}; -use iter::FromIterator; +use hash::{Hash, Hasher}; +#[cfg(stage0)] use hash::Writer; +use iter::{FromIterator, IntoIterator}; use mem; use num::Int; use ops; @@ -356,9 +357,9 @@ impl Wtf8Buf { /// This replaces surrogate code point pairs with supplementary code points, /// like concatenating ill-formed UTF-16 strings effectively would. impl FromIterator<CodePoint> for Wtf8Buf { - fn from_iter<T: Iterator<Item=CodePoint>>(iterator: T) -> Wtf8Buf { + fn from_iter<T: IntoIterator<Item=CodePoint>>(iter: T) -> Wtf8Buf { let mut string = Wtf8Buf::new(); - string.extend(iterator); + string.extend(iter); string } } @@ -368,7 +369,8 @@ impl FromIterator<CodePoint> for Wtf8Buf { /// This replaces surrogate code point pairs with supplementary code points, /// like concatenating ill-formed UTF-16 strings effectively would. impl Extend<CodePoint> for Wtf8Buf { - fn extend<T: Iterator<Item=CodePoint>>(&mut self, iterator: T) { + fn extend<T: IntoIterator<Item=CodePoint>>(&mut self, iterable: T) { + let iterator = iterable.into_iter(); let (low, _high) = iterator.size_hint(); // Lower bound of one byte per code point (ASCII only) self.bytes.reserve(low); @@ -794,13 +796,22 @@ impl<'a> Iterator for EncodeWide<'a> { } } +#[cfg(stage0)] impl<S: Writer + Hasher> Hash<S> for CodePoint { #[inline] fn hash(&self, state: &mut S) { self.value.hash(state) } } +#[cfg(not(stage0))] +impl Hash for CodePoint { + #[inline] + fn hash<H: Hasher>(&self, state: &mut H) { + self.value.hash(state) + } +} +#[cfg(stage0)] impl<S: Writer + Hasher> Hash<S> for Wtf8Buf { #[inline] fn hash(&self, state: &mut S) { @@ -808,7 +819,16 @@ impl<S: Writer + Hasher> Hash<S> for Wtf8Buf { 0xfeu8.hash(state) } } +#[cfg(not(stage0))] +impl Hash for Wtf8Buf { + #[inline] + fn hash<H: Hasher>(&self, state: &mut H) { + state.write(&self.bytes); + 0xfeu8.hash(state) + } +} +#[cfg(stage0)] impl<'a, S: Writer + Hasher> Hash<S> for Wtf8 { #[inline] fn hash(&self, state: &mut S) { @@ -816,6 +836,14 @@ impl<'a, S: Writer + Hasher> Hash<S> for Wtf8 { 0xfeu8.hash(state) } } +#[cfg(not(stage0))] +impl Hash for Wtf8 { + #[inline] + fn hash<H: Hasher>(&self, state: &mut H) { + state.write(&self.bytes); + 0xfeu8.hash(state) + } +} impl AsciiExt for Wtf8 { type Owned = Wtf8Buf; |
