Skip to content

vec! macro should use box [...] instead of Box::new([...]). #28950

Closed
@eddyb

Description

@eddyb

There's no reason to have the potentially unoptimizable inefficiency in vec!.
It's impossible to reoder side-effects (which is why we want placement syntax), so vec![expressions, containing, side, effects] will end up in a copy from the stack to the heap.

I guess it's not as bad as I thought given that vec![x; N] goes through a more optimal route so you can't cause a stack overflow with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions