Make derive(Clone) implement clone_from as well

Currently #[derive(Clone)] only implements fn clone(&self) -> Self, leaves fn clone_from(&mut self, source: &Self) unimplemented. This makes clone_from with usual structs/enums far less useful than it should be. My question is, would it be possible to make #[derive(Clone)] to generate proper clone_from implementation? Technically it's a breaking change though it should purely be an optimization. Does it sounds feasible to change builtin derive macro in this way?

See https://github.com/rust-lang/rust/pull/98445#issuecomment-1190681305

3 Likes