[rust-dev] Fwd: &self/&mut self in traits considered harmful(?)

comex comexk at gmail.com
Mon Jun 16 23:24:08 PDT 2014


On Mon, Jun 16, 2014 at 5:24 PM, Patrick Walton <pcwalton at mozilla.com> wrote:
> I don't see much of a use case for `Add` without move semantics. Does anyone
> have any?
>
> Strings and vectors, perhaps, but I would argue that having to call
> `.clone()` on the LHS or RHS (as appropriate) is an improvement, because
> cloning strings and vectors can be very expensive.

For a vector, calling .clone() on either side is guaranteed to make a
duplicate copy, since a cloned LHS will have capacity = size and will
have to be thrown away in favor of a larger combined buffer.


More information about the Rust-dev mailing list