-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
I've made a simple Godbolt for a demonstration of the approach.
In short, with array::map stabilized in 1.55 it's now possible to make an array [T; N]
of default values of T
by invoking [(); N].map(|_| T::default())
. There is no difference in the emitted assembly for either O2 or O3 optimization levels in my short example for usize
and user defined type (both ZST and not ZST), but obviously there is no guarantee that some more complex cases would not diverge.
I would expect that lifting a hard limitation of 32 on the size of the array would be handy in general.
Metadata
Metadata
Assignees
Labels
T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.