-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
proposal: Assign trait #4329
Copy link
Copy link
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Type
Fields
Give feedbackNo fields configured for issues without a type.
At the moment,
a = b.clone()is the way to copy-assign to a value in generic code (at least once there's a default implementation forCopyable types, per #3313).If
ais uninitialized, that's perfectly optimal. When the value is already initialized, assignment can often be done with fewer allocations; a list or chunked list can be partially or fully reused, and even a vector/string can often be reused if it's big enough.So, something like this (with a default impl for
Cloneable types):There's no need for any operator overload, since
a = bis just an implicit copy or a move.