diff options
| author | bors <bors@rust-lang.org> | 2016-08-08 14:59:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-08 14:59:30 -0700 |
| commit | 080e0e072f9c654893839cf1f7ea71dc153b08a9 (patch) | |
| tree | 3c3cde39aabb028d560daa178ffd6ba304c045bd | |
| parent | f84008b5586b0c35b117df2bc34410ad1d1a4e86 (diff) | |
| parent | 42e64bc5f2b5c7ff9a1619cc267d0fb7ac23f1d0 (diff) | |
| download | rust-080e0e072f9c654893839cf1f7ea71dc153b08a9.tar.gz rust-080e0e072f9c654893839cf1f7ea71dc153b08a9.zip | |
Auto merge of #35064 - pthariensflame:feature/cow_str_from_iter, r=alexcrichton
Add `FromIterator` implementations for `Cow<str>` This seems like an oversight, since the corresponding implementation for `Cow<[T]> where T: Clone` exists.
| -rw-r--r-- | src/libcollections/string.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 06952253ef3..70b514afd03 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1874,6 +1874,27 @@ impl<'a> From<String> for Cow<'a, str> { } } +#[stable(feature = "cow_str_from_iter", since = "1.12.0")] +impl<'a> FromIterator<char> for Cow<'a, str> { + fn from_iter<I: IntoIterator<Item = char>>(it: I) -> Cow<'a, str> { + Cow::Owned(FromIterator::from_iter(it)) + } +} + +#[stable(feature = "cow_str_from_iter", since = "1.12.0")] +impl<'a, 'b> FromIterator<&'b str> for Cow<'a, str> { + fn from_iter<I: IntoIterator<Item = &'b str>>(it: I) -> Cow<'a, str> { + Cow::Owned(FromIterator::from_iter(it)) + } +} + +#[stable(feature = "cow_str_from_iter", since = "1.12.0")] +impl<'a> FromIterator<String> for Cow<'a, str> { + fn from_iter<I: IntoIterator<Item = String>>(it: I) -> Cow<'a, str> { + Cow::Owned(FromIterator::from_iter(it)) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl Into<Vec<u8>> for String { fn into(self) -> Vec<u8> { |
