Skip to content

Commit

Permalink
Auto merge of #35064 - pthariensflame:feature/cow_str_from_iter, r=al…
Browse files Browse the repository at this point in the history
…excrichton

Add `FromIterator` implementations for `Cow<str>`

This seems like an oversight, since the corresponding implementation for `Cow<[T]> where T: Clone` exists.
  • Loading branch information
bors authored Aug 8, 2016
2 parents f84008b + 42e64bc commit 080e0e0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 080e0e0

Please sign in to comment.