diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 14:34:08 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 14:34:08 -0800 |
| commit | 5a32b4a34fc6fbd78e293b16f7ba7d06caca7a48 (patch) | |
| tree | ea0ee2df4161fb0578705cd5f26635db5f3b4a1e /src/libcollections/string.rs | |
| parent | 9aee389b6e5a58eb867f4d035729f39e694f51ec (diff) | |
| parent | 66613e26b95438c02e2f5c273c557515454121f7 (diff) | |
| download | rust-5a32b4a34fc6fbd78e293b16f7ba7d06caca7a48.tar.gz rust-5a32b4a34fc6fbd78e293b16f7ba7d06caca7a48.zip | |
rollup merge of #22491: Gankro/into_iter
Conflicts: src/libcollections/bit.rs src/libcollections/linked_list.rs src/libcollections/vec_deque.rs src/libstd/sys/common/wtf8.rs
Diffstat (limited to 'src/libcollections/string.rs')
| -rw-r--r-- | src/libcollections/string.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 6204c4427b5..db889725abd 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -21,7 +21,7 @@ use core::default::Default; use core::error::Error; use core::fmt; use core::hash; -use core::iter::FromIterator; +use core::iter::{IntoIterator, FromIterator}; use core::mem; use core::ops::{self, Deref, Add, Index}; use core::ptr; @@ -709,18 +709,18 @@ impl Error for FromUtf16Error { #[stable(feature = "rust1", since = "1.0.0")] impl FromIterator<char> for String { - fn from_iter<I:Iterator<Item=char>>(iterator: I) -> String { + fn from_iter<I: IntoIterator<Item=char>>(iter: I) -> String { let mut buf = String::new(); - buf.extend(iterator); + buf.extend(iter); buf } } #[stable(feature = "rust1", since = "1.0.0")] impl<'a> FromIterator<&'a str> for String { - fn from_iter<I:Iterator<Item=&'a str>>(iterator: I) -> String { + fn from_iter<I: IntoIterator<Item=&'a str>>(iter: I) -> String { let mut buf = String::new(); - buf.extend(iterator); + buf.extend(iter); buf } } @@ -728,7 +728,8 @@ impl<'a> FromIterator<&'a str> for String { #[unstable(feature = "collections", reason = "waiting on Extend stabilization")] impl Extend<char> for String { - fn extend<I:Iterator<Item=char>>(&mut self, iterator: I) { + fn extend<I: IntoIterator<Item=char>>(&mut self, iterable: I) { + let iterator = iterable.into_iter(); let (lower_bound, _) = iterator.size_hint(); self.reserve(lower_bound); for ch in iterator { @@ -740,7 +741,8 @@ impl Extend<char> for String { #[unstable(feature = "collections", reason = "waiting on Extend stabilization")] impl<'a> Extend<&'a str> for String { - fn extend<I: Iterator<Item=&'a str>>(&mut self, iterator: I) { + fn extend<I: IntoIterator<Item=&'a str>>(&mut self, iterable: I) { + let iterator = iterable.into_iter(); // A guess that at least one byte per iterator element will be needed. let (lower_bound, _) = iterator.size_hint(); self.reserve(lower_bound); |
