[rust-dev] On Copy = POD

Igor Bukanov igor at mir2.org
Sat Jun 21 10:52:53 PDT 2014

On 21 June 2014 11:10, Nick Cameron <lists at ncameron.org> wrote:
> I wonder if we could come up with _some_
> design that would be better than the current one.

The reason the ugliness is the repeated clone calls:

    let x = Rc::<int>::new(1);

In this pattern the x is repeatedly cloned to pass it as argument that
will be moved. The ugliness can be eliminated if x as the local
variable can be annotated to tell the compiler to clone it before
passing to functions. I.e. something like:

    let autoclone x = Rc::<int>::new(1);

Another possibility is to allow for move-in-move-out params that moves
the the value back to the caller when the function returns forcing the
callee to use the clone call if it wants to store the argument for a
later use.

More information about the Rust-dev mailing list