-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement From<&[T; N]>
and From<&mut [T; N]>
for Vec<T>
where T: Clone
?
#100880
Comments
@rustbot claim |
Can you help me with runnable code to understand why the @rustbot label +T-libs-api |
Ah ok, maybe I understand what do you mean, currently we can do use std::vec::Vec;
#[derive(Clone, Copy, Debug)]
struct Type;
fn main() {
let mut array = [Type{}];
let mut vect = vec![];
vect.extend_from_slice(&array);
println!("{:?}", vect);
} And your proposal is to support use std::vec::Vec;
#[derive(Clone, Copy, Debug)]
struct Type;
fn main() {
let mut array = [Type{}];
let mut vect = Vec::from(&array);
println!("{:?}", vect);
} |
@vincenzopalazzo I don’t have a use case for fn foo(value: Option<&[String; 2]>) -> Option<Vec<String>> {
value.map(Vec::from)
} instead of fn foo(value: Option<&[String; 2]>) -> Option<Vec<String>> {
value.map(<[_; 2]>::as_slice).map(Vec::from)
} |
Currently we have
impl From<&[T]> for Vec<T> where T: Clone
andimpl From<&mut [T]> for Vec<T> where T: Clone
, shouldFrom<&[T; N]>
andFrom<&mut [T; N]>
also be implemented forVec<T>
whereT: Clone
?The text was updated successfully, but these errors were encountered: