Implement From<&mut [T]> for Vec

This commit is contained in:
Guillaume Gomez 2017-04-25 12:34:45 +02:00
parent 0777c757a6
commit e70a266b3b
1 changed files with 12 additions and 0 deletions

View File

@ -1984,6 +1984,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> {