-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries
Description
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
From<&[T]>
.From<&mut [T]>
.- Implementation PR: Implement
From<{&,&mut} [T; N]>
forVec<T>
whereT: Clone
rust#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.
Metadata
Metadata
Assignees
Labels
ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)API Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard librariesA proposal to add or alter unstable APIs in the standard libraries