impl FromIter<&char> for String

This commit is contained in:
Without Boats 2017-02-22 00:06:40 -08:00
parent fc6f092c21
commit 097398e383

View file

@ -1480,6 +1480,15 @@ impl FromIterator<char> for String {
}
}
#[stable(feature = "string_from_iter_by_ref", since = "1.17.0")]
impl<'a> FromIterator<&'a char> for String {
fn from_iter<I: IntoIterator<Item = &'a char>>(iter: I) -> String {
let mut buf = String::new();
buf.extend(iter);
buf
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a> FromIterator<&'a str> for String {
fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> String {