Skip to content

Commit b78d276

Browse files
author
Jorge Aparicio
committed
add section on taking the RHS by ref vs by value
1 parent 8d5b133 commit b78d276

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

text/0000-op-assign.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ Once we feel comfortable with the implementation we'll remove the feature gate
5050
and mark the traits as stable. This can be done after 1.0 as this change is
5151
backwards compatible.
5252

53+
## RHS: By ref vs by value
54+
55+
This RFC proposes that the assignment operations take the RHS always by ref;
56+
instead of by value like the "normal" binary operations (e.g. `Add`) do. The
57+
rationale is that, as far as the author has seen in practice [1], one never
58+
wants to mutate the RHS or consume it, or in other words an immutable view into
59+
the RHS is enough to perform the operation. Therefore, this RFC follows in the
60+
footsteps of the `Index` traits, where the same situation arises with the
61+
indexing value, and by ref was chosen over by value.
62+
63+
[1] It could be possible that the author is not aware of use cases where taking
64+
RHS by value is necessary. Feedback on this matter would be appreciated. (See
65+
the first unresolved question)
66+
5367
# Drawbacks
5468

5569
None that I can think of.

0 commit comments

Comments
 (0)