Skip to content

Commit

Permalink
Rollup merge of rust-lang#41530 - GuillaumeGomez:vec-from, r=aturon
Browse files Browse the repository at this point in the history
Implement From<&mut [T]> for Vec

Fixes rust-lang#41386.
  • Loading branch information
frewsxcv authored Apr 26, 2017
2 parents 9ae413c + e70a266 commit e2a0467
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit e2a0467

Please sign in to comment.