Rollup merge of #68692 - jyn514:vec-from-array, r=LukasKalbertodt
impl From<[T; N]> for Vec<T> Closes https://github.com/rust-lang/rust/issues/67963
This commit is contained in:
commit
c51fcb5f38
4 changed files with 41 additions and 7 deletions
|
@ -1,3 +1,4 @@
|
|||
// ignore-tidy-filelength
|
||||
//! A contiguous growable array type with heap-allocated contents, written
|
||||
//! `Vec<T>`.
|
||||
//!
|
||||
|
@ -2398,6 +2399,21 @@ impl<T: Clone> From<&mut [T]> for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "vec_from_array", since = "1.44.0")]
|
||||
impl<T, const N: usize> From<[T; N]> for Vec<T>
|
||||
where
|
||||
[T; N]: LengthAtMost32,
|
||||
{
|
||||
#[cfg(not(test))]
|
||||
fn from(s: [T; N]) -> Vec<T> {
|
||||
<[T]>::into_vec(box s)
|
||||
}
|
||||
#[cfg(test)]
|
||||
fn from(s: [T; N]) -> Vec<T> {
|
||||
crate::slice::into_vec(box s)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "vec_from_cow_slice", since = "1.14.0")]
|
||||
impl<'a, T> From<Cow<'a, [T]>> for Vec<T>
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue