diff options
| author | Alexis <a.beingessner@gmail.com> | 2015-02-18 10:04:30 -0500 |
|---|---|---|
| committer | Alexis <a.beingessner@gmail.com> | 2015-02-18 14:01:47 -0500 |
| commit | 4a9d190423f67a00053f4b5c9869f0ccbdfcc689 (patch) | |
| tree | 60afef47fda69fcaac8378825244a6cb0c41663a /src/libstd | |
| parent | 5fa9de16df87ab844452821acff1b6c74e948327 (diff) | |
| download | rust-4a9d190423f67a00053f4b5c9869f0ccbdfcc689.tar.gz rust-4a9d190423f67a00053f4b5c9869f0ccbdfcc689.zip | |
make Extend use IntoIterator
This breaks all implementors of Extend, as they must now accept IntoIterator instead of Iterator. The fix for this is generally trivial (change the bound, and maybe call into_iter() on the argument to get the old argument). Users of Extend should be unaffected because Iterators are IntoIterator. [breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 2 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 2 | ||||
| -rwxr-xr-x | src/libstd/path.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/common/wtf8.rs | 5 |
4 files changed, 7 insertions, 6 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 1b9f8b99017..61b531054a0 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1570,7 +1570,7 @@ impl<K, V, S, H> Extend<(K, V)> for HashMap<K, V, S> S: HashState<Hasher=H>, H: hash::Hasher<Output=u64> { - fn extend<T: Iterator<Item=(K, V)>>(&mut self, iter: T) { + fn extend<T: IntoIterator<Item=(K, V)>>(&mut self, iter: T) { for (k, v) in iter { self.insert(k, v); } diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 5fbbcb3b347..f5e57b78d2a 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -636,7 +636,7 @@ impl<T, S, H> Extend<T> for HashSet<T, S> S: HashState<Hasher=H>, H: hash::Hasher<Output=u64> { - fn extend<I: Iterator<Item=T>>(&mut self, iter: I) { + fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I) { for k in iter { self.insert(k); } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 1d992668900..f25cc83b93e 100755 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -110,7 +110,7 @@ use core::prelude::*; use ascii::*; use borrow::BorrowFrom; use cmp; -use iter; +use iter::{self, IntoIterator}; use mem; use ops::{self, Deref}; use string::CowString; @@ -961,7 +961,7 @@ impl<'a, P: ?Sized + 'a> iter::FromIterator<&'a P> for PathBuf where P: AsPath { } impl<'a, P: ?Sized + 'a> iter::Extend<&'a P> for PathBuf where P: AsPath { - fn extend<I: Iterator<Item = &'a P>>(&mut self, iter: I) { + fn extend<I: IntoIterator<Item = &'a P>>(&mut self, iter: I) { for p in iter { self.push(p) } diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index b610f6c370b..e7cb67c6287 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -32,7 +32,7 @@ use borrow::Cow; use cmp; use fmt; use hash::{Hash, Writer, Hasher}; -use iter::FromIterator; +use iter::{FromIterator, IntoIterator}; use mem; use num::Int; use ops; @@ -368,7 +368,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); |
