impl<T> Clone for T where T: Copy

Sorry i can’t remember, but what stopped us from having the definition as below.in libcore?

    impl<T> Clone for T where T: Copy {
        fn clone(&self) -> T {
            *self
        }
    }

EDIT: And remove Copy's supertrait Clone, of course!

2 Likes

Take something like Option<T> which conditionally implements Copy – if that implies Clone, then how can it implement Clone apart from that?

1 Like

Why does it need to? When it implements Copy, it will automatically implement Clone given the impl in the OP, doesn’t it?

Oh the impls overlapped (although their effect will be the same), yes i see what you mean.

This is the kind of thing we want to do if we could get specialization to a place we could stabilize it.

5 Likes
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.