Skip to content

Commit e2a0467

Browse files
authored
Rollup merge of #41530 - GuillaumeGomez:vec-from, r=aturon
Implement From<&mut [T]> for Vec Fixes #41386.
2 parents 9ae413c + e70a266 commit e2a0467

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Diff for: src/libcollections/vec.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2033,6 +2033,18 @@ impl<'a, T: Clone> From<&'a [T]> for Vec<T> {
20332033
}
20342034
}
20352035

2036+
#[stable(feature = "vec_from_mut", since = "1.21.0")]
2037+
impl<'a, T: Clone> From<&'a mut [T]> for Vec<T> {
2038+
#[cfg(not(test))]
2039+
fn from(s: &'a mut [T]) -> Vec<T> {
2040+
s.to_vec()
2041+
}
2042+
#[cfg(test)]
2043+
fn from(s: &'a mut [T]) -> Vec<T> {
2044+
::slice::to_vec(s)
2045+
}
2046+
}
2047+
20362048
#[stable(feature = "vec_from_cow_slice", since = "1.14.0")]
20372049
impl<'a, T> From<Cow<'a, [T]>> for Vec<T> where [T]: ToOwned<Owned=Vec<T>> {
20382050
fn from(s: Cow<'a, [T]>) -> Vec<T> {

0 commit comments

Comments
 (0)