Closed as not planned
Closed as not planned
Description
I tried this code:
struct A;
impl Clone for A {
fn clone(&self) -> Self {
println!("Basic clone");
Self
}
fn clone_from(&mut self, other: &Self) {
println!("Clone from");
*self = Self;
}
}
#[derive(Clone)]
struct B(A);
fn main() {
let b = B(A);
let mut bb = B(A);
bb.clone_from(&b);
}
I expected to see this happen: prints Clone from
Instead, this happened: prints Basic clone
I think, this can lead to little losses for types which have multiple vector and string fields.
Meta
rustc --version --verbose
:
rustc 1.61.0 (fe5b13d68 2022-05-18)
binary: rustc
commit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e
commit-date: 2022-05-18
host: x86_64-unknown-linux-gnu
release: 1.61.0
LLVM version: 14.0.0
rustc 1.63.0-nightly (5750a6aa2 2022-06-20)
binary: rustc
commit-hash: 5750a6aa2777382bf421b726f234da23f990a953
commit-date: 2022-06-20
host: x86_64-unknown-linux-gnu
release: 1.63.0-nightly
LLVM version: 14.0.5