On 07/18/2013 04:24 AM, Corey Richardson wrote:
So with decopy landed we now have no way to copy things that does not
require author intervention. And I am ok with this! Clone is much more
flexible, less magic, etc. I see one problem with this though: we have
no way to copy things that does not require author intervention.

For example, I ran into this with rustdoc_ng: there is no Clone
implementation for syntax::ast::struct_def. There's no reason it
couldn't have one, it's just that it wasn't needed to be cloned, so an
implementation wasn't added (via #[deriving(Clone)]).

This is a problem. If a library author overlooks something that
could/should have Clone, users of that library are now with no way to
copy.

I propose the following:

If a given struct/enum has no Clone implementation, it fulfills the
requirements of the now-gone Copy kind, and the #[no_clone] attribute
is not present, #[deriving(Clone)] is automatically applied to it.

I'm not that fond of this sort of magic but it seems to be necessary:
library authors aren't perfect, and a simple oversight can harmfully
limiting what can be done with its types.

I disagree with the premise. There are any number of valid traits that library authors can forget to implement. Clone isn't special here.

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to