FromIterator and Extend Cow for String
This commit is contained in:
parent
810ed98d08
commit
0e2571b4ad
1 changed files with 18 additions and 0 deletions
|
@ -1604,6 +1604,15 @@ impl FromIterator<String> for String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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 {
|
||||||
|
let mut buf = String::new();
|
||||||
|
buf.extend(iter);
|
||||||
|
buf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl Extend<char> for String {
|
impl Extend<char> for String {
|
||||||
fn extend<I: IntoIterator<Item = char>>(&mut self, iter: I) {
|
fn extend<I: IntoIterator<Item = char>>(&mut self, iter: I) {
|
||||||
|
@ -1641,6 +1650,15 @@ impl Extend<String> for String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[stable(feature = "herd_cows", since = "1.19.0")]
|
||||||
|
impl<'a> Extend<Cow<'a, str>> for String {
|
||||||
|
fn extend<I: IntoIterator<Item = Cow<'a, str>>>(&mut self, iter: I) {
|
||||||
|
for s in iter {
|
||||||
|
self.push_str(&s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A convenience impl that delegates to the impl for `&str`
|
/// A convenience impl that delegates to the impl for `&str`
|
||||||
#[unstable(feature = "pattern",
|
#[unstable(feature = "pattern",
|
||||||
reason = "API not fully fleshed out and ready to be stabilized",
|
reason = "API not fully fleshed out and ready to be stabilized",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue