Skip to content

make creating arrays of types that are not Copy less painful #1109

Description

@vks

It would be very nice if

let array = [$expression; N];

was syntactic sugar for

let array = [$expression, $expression, $expression, ...];

This would allow things like

let bools = [AtomicBool::new(false); 10];
let array: [T; 10] = [Default::default(); 10];

Currently it only works for values that implement Copy. For the use case above, there is currently not really any alternative to just writing [$expr, $expr, ...].

I think this is a backwards-compatible change.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions