Skip to content

Commit

Permalink
Implement From<&mut [T]> for Vec
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 25, 2017
1 parent 0777c75 commit e70a266
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libcollections/vec.rs
Expand Up @@ -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> {
Expand Down

0 comments on commit e70a266

Please sign in to comment.