1
Fork 0

Rollup merge of #41530 - GuillaumeGomez:vec-from, r=aturon

Implement From<&mut [T]> for Vec

Fixes #41386.
This commit is contained in:
Corey Farwell 2017-04-25 23:06:00 -04:00 committed by GitHub
commit e2a04678da

View file

@ -2033,6 +2033,18 @@ impl<'a, T: Clone> From<&'a [T]> for Vec<T> {
}
}
#[stable(feature = "vec_from_mut", since = "1.21.0")]
impl<'a, T: Clone> From<&'a mut [T]> for Vec<T> {
#[cfg(not(test))]
fn from(s: &'a mut [T]) -> Vec<T> {
s.to_vec()
}
#[cfg(test)]
fn from(s: &'a mut [T]) -> Vec<T> {
::slice::to_vec(s)
}
}
#[stable(feature = "vec_from_cow_slice", since = "1.14.0")]
impl<'a, T> From<Cow<'a, [T]>> for Vec<T> where [T]: ToOwned<Owned=Vec<T>> {
fn from(s: Cow<'a, [T]>) -> Vec<T> {