←back to thread

128 points RGBCube | 3 comments | | HN request time: 0s | source
Show context
hyperbrainer ◴[] No.44497751[source]
> we cannot just require all generic parameters to be Clone, as we cannot assume they are used in such a way that requires them to be cloned.

I don't understand what "used in such a way requires them to be cloned" means. Why would you require that?

replies(3): >>44497760 #>>44497770 #>>44497789 #
1. xvedejas ◴[] No.44497770[source]
Right now the derive macro requires `T` be `Clone`, but what we actually want to require is only that each field is clone, including those that are generic over `T`. eg `Arc<T>` is `Clone` even though `T` isn't, so the correct restriction would be to require `Arc<T>: Clone` instead of the status quo which requires `T: Clone`
replies(2): >>44499508 #>>44499631 #
2. nithssh ◴[] No.44499508[source]
This is the best explanation I've read of this limitation
3. Xunjin ◴[] No.44499631[source]
Thank you, summarized perfectly.