Skip to content

#[derive(Clone)] should explicitly override clone_from #13281

Closed
@huonw

Description

@huonw

This would mean derived clone implementations can reuse the resources of interior types (especially important with types containing things like Vec) when cloning into an already-created instance.

Currently doing this is difficult with how #[deriving] works internally (needs a mutable borrow of the contents of self, and needs to avoid borrowing self for enum variants that mismatch or else the requisite *self = other.clone() implementation won't work).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions