Skip to content

Commit

Permalink
added .collect() into String from Box<str> with fake feature/stabilit…
Browse files Browse the repository at this point in the history
…y annotation
  • Loading branch information
djugei committed May 27, 2020
1 parent 52b605c commit b4337ab
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/liballoc/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1772,6 +1772,15 @@ impl FromIterator<String> for String {
}
}

#[stable(feature = "box_str2", since = "1.45.0")]
impl FromIterator<Box<str>> for String {
fn from_iter<I: IntoIterator<Item = Box<str>>>(iter: I) -> String {
let mut buf = String::new();
buf.extend(iter);
buf
}
}

#[stable(feature = "herd_cows", since = "1.19.0")]
impl<'a> FromIterator<Cow<'a, str>> for String {
fn from_iter<I: IntoIterator<Item = Cow<'a, str>>>(iter: I) -> String {
Expand Down Expand Up @@ -1815,6 +1824,13 @@ impl<'a> Extend<&'a str> for String {
}
}

#[stable(feature = "box_str2", since = "1.45.0")]
impl Extend<Box<str>> for String {
fn extend<I: IntoIterator<Item = Box<str>>>(&mut self, iter: I) {
iter.into_iter().for_each(move |s| self.push_str(&s));
}
}

#[stable(feature = "extend_string", since = "1.4.0")]
impl Extend<String> for String {
fn extend<I: IntoIterator<Item = String>>(&mut self, iter: I) {
Expand Down

0 comments on commit b4337ab

Please sign in to comment.