Proposal
Problem statement
Currently, we have From<{&,&mut} [T]> for Vec<T> where T: Clone, I think we can also implement From<{&,&mut} [T; N]> for Vec<T> where T: Clone.
Motivation, use-cases
Suppose I want to convert an &[[u32; 4]] value to a Vec<Vec<u32>> type. Currently, I can write:
items.iter().map(|item| item.to_vec()).collect::<Vec<_>>();
items.iter().copied().map(Vec::from).collect::<Vec<_>>();
I want to be able to write:
items.iter().map(Vec::from).collect::<Vec<_>>();
Solution sketches
Implement From<{&,&mut} [T; N]> for Vec<T> where T: Clone.
Links and related work
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Proposal
Problem statement
Currently, we have
From<{&,&mut} [T]>forVec<T>whereT: Clone, I think we can also implementFrom<{&,&mut} [T; N]>forVec<T>whereT: Clone.Motivation, use-cases
Suppose I want to convert an
&[[u32; 4]]value to aVec<Vec<u32>>type. Currently, I can write:items.iter().map(|item| item.to_vec()).collect::<Vec<_>>();items.iter().copied().map(Vec::from).collect::<Vec<_>>();I want to be able to write:
items.iter().map(Vec::from).collect::<Vec<_>>();Solution sketches
Implement
From<{&,&mut} [T; N]>forVec<T>whereT: Clone.Links and related work
From<&[T]>.From<&mut [T]>.From<{&,&mut} [T; N]>forVec<T>whereT: Clonerust#111278.What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.