Skip to content

Implement conversion methods between Vecs of AST enums which inherit from each other #153

@overlookmotel

Description

@overlookmotel

We have zero-cost conversion methods for converting e.g. From<Expression> for Argument. It's zero cost because Argument inherits Expression's variants, so a valid Expression is also a valid Argument, and the conversion is just an in-place transmute.

Implement the same for converting Vecs. e.g. Vec<'a, Expression<'a>> should be able to be converted to Vec<'a, Argument<'a>> as a zero cost transmute - without memory copy or allocation.

Ditto From<Box<'a, Expression<'a>>> for Box<'a, Argument<'a>>. Edit: No point. We never box enums.

The code touched in oxc-project/oxc#7854 is an example of where we could use this for a more efficient operation.

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