Skip to content

ACP: Make <[[T; N]]>::flatten const #218

Closed

Description

Proposal

Problem statement

Allow using <[[T; N]]>::flatten within const fn.

Motivation, use-cases

Could be useful for code like this where you have an array containing arrays (for instance from u32::to_be_bytes) to return an array. For example, Ipv6Addr::new in standard library could make use of it.

[f(a), f(b), f(c), f(d)].flatten().try_into().unwrap()

Solution sketches

Add const keyword. The current implementation is already const-compatible, and I don't see a reason why this would change.

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 in its weekly meeting. You should receive feedback within a week or two.

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

Metadata

Assignees

No one assigned

    Labels

    ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions