1
Fork 0

Rollup merge of #50170 - burtonageo:more_cow_from, r=alexcrichton

Implement From for more types on Cow

This is basically https://github.com/rust-lang/rust/pull/48191, except that it should be implemented in a way that doesn't break third party crates.
This commit is contained in:
kennytm 2018-05-17 05:22:07 +08:00
commit 8366780164
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
5 changed files with 95 additions and 0 deletions

View file

@ -2286,6 +2286,13 @@ impl<'a, T: Clone> From<Vec<T>> for Cow<'a, [T]> {
}
}
#[stable(feature = "cow_from_vec_ref", since = "1.28.0")]
impl<'a, T: Clone> From<&'a Vec<T>> for Cow<'a, [T]> {
fn from(v: &'a Vec<T>) -> Cow<'a, [T]> {
Cow::Borrowed(v.as_slice())
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Cow<'a, [T]> {