Skip to content

Implement Default for all array sizes #88744

Closed

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    T-libsRelevant 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions