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

Daniel Micay danielmicay at gmail.com
Wed Jun 11 11:33:40 PDT 2014


On 11/06/14 01:54 PM, Tommi wrote:
> If the `Mul` trait and similar were changed to take `self` by value, perhaps the following kind of language design would make more sense:
> 
> If a variable of a type that has a destructor is passed to a function by value (moved), and the variable is used after the function call, the variable would be implicitly cloned before passing it to the function.

Cloning big integers, rationals based on big integers or arbitrary
precision floating point values for every single operation has a high
cost. One of Rust's strength's is that it doesn't have implicit cloning
as C++ does due to copy constructors.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140611/bdbe23e1/attachment.sig>


More information about the Rust-dev mailing list