A new take on Move, Copy, and assignment #1506
Replies: 2 comments 1 reply
-
One use case we had in mind for a type that is movable but might require a custom |
Beta Was this translation helpful? Give feedback.
-
You mean under
Note: non-movable types include any type with remote parts (e.g., a capturing lambda). If the
Now if we had
and
Yes Another transformation to consider is the return from a function. Assume we have |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@kyouko-taiga and I chatted today about
Movable
andCopyable
and decided there was room for more symmetry. I'm writing this up to capture that idea and nail down a few things we didn't discuss explicitly to make sure there's agreement.First, the traits as they should be defined:
Initialization and assignment are tied to these traits, so
Will use the
set
variant ofMovable.move_value(from: rhs)
or ofCopyable.copy_value(from: rhs)
in caserhs
is used again.Will use the
inout
variant ofMovable.move_value(from: rhs)
or ofCopyable.copy_value(from: rhs)
in caserhs
is used again.Additional
.move()
or.copy()
operations onrhs
can be elided by the compiler in each of these cases.Beta Was this translation helpful? Give feedback.
All reactions