Skip to content

Commit 080e0e0

Browse files
authoredAug 8, 2016
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.
2 parents f84008b + 42e64bc commit 080e0e0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎src/libcollections/string.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,27 @@ impl<'a> From<String> for Cow<'a, str> {
18741874
}
18751875
}
18761876

1877+
#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
1878+
impl<'a> FromIterator<char> for Cow<'a, str> {
1879+
fn from_iter<I: IntoIterator<Item = char>>(it: I) -> Cow<'a, str> {
1880+
Cow::Owned(FromIterator::from_iter(it))
1881+
}
1882+
}
1883+
1884+
#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
1885+
impl<'a, 'b> FromIterator<&'b str> for Cow<'a, str> {
1886+
fn from_iter<I: IntoIterator<Item = &'b str>>(it: I) -> Cow<'a, str> {
1887+
Cow::Owned(FromIterator::from_iter(it))
1888+
}
1889+
}
1890+
1891+
#[stable(feature = "cow_str_from_iter", since = "1.12.0")]
1892+
impl<'a> FromIterator<String> for Cow<'a, str> {
1893+
fn from_iter<I: IntoIterator<Item = String>>(it: I) -> Cow<'a, str> {
1894+
Cow::Owned(FromIterator::from_iter(it))
1895+
}
1896+
}
1897+
18771898
#[stable(feature = "rust1", since = "1.0.0")]
18781899
impl Into<Vec<u8>> for String {
18791900
fn into(self) -> Vec<u8> {

0 commit comments

Comments
 (0)
Please sign in to comment.