On Fri, Jan 17, 2014 at 7:53 PM, Josh Haberman <[email protected]> wrote:
>
> Are you saying (if I may lapse into C++ vocab for a moment) that I can't
> hide the copy constructor? Anyone can copy my non-mut struct into a
> mut struct at any time and I don't have any say in the matter?
>
> Feel free to correct this into Rust-speak.  :)

Every type in Rust can be assigned, passed or returned by-value. This
is always semantically equivalent to a shallow copy, as they are in C.
If the type has a destructor, closure or `&mut T` inside then the copy
is considered a move of ownership.

That's why there's a `Clone` trait in the standard library. It's the
minimum work to go from a non-owning reference to a value, rather than
just being the built-in shallow copy potentially moving ownership from
the source to the destination.

You're also free to make fields private.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to