Do not implement Copy for types with "&mut self" methods #116
newpavlov
started this conversation in
API Guidelines
Replies: 1 comment
-
Thanks! We definitely need a guideline for this. Relevant discussions in the standard library related to Copy for range iterators in the following sequence of PRs:
One of the motivating examples there was: let mut iter = 0..n;
for i in iter { if i > 2 { break; } }
iter.collect() With a Copy impl, this iterates over a copy of the range and then |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Implicit copies of types with methods accepting
&mut self
can produce surprising results for library users. Thus it's probably worth to add recommendation to avoid derivingCopy
trait for such types.Related issue.
Beta Was this translation helpful? Give feedback.
All reactions