clone() — explicit deep copy (duplicates all data). Copy — implicit bitwise copy (always cheap).
clone():
.clone() method.Clone trait.1let s1 = String::from("hello");2let s2 = s1.clone(); // s2 has its own "hello"3println!("{} {}", s1, s2); // Both valid45let v1 = vec![1, 2, 3];6let v2 = v1.clone(); // v2 is separate Vec
Copy trait:
Clone if implementing Copy.1let x: i32 = 42;2let y = x; // Implicit copy — x still valid3println!("{} {}", x, y); // 42 4245let point = (1, 2); // Tuple of Copy types → Copy6let point2 = point;
When to use:
clone() when you need explicit ownership.Common mistakes:
String implements Copy — it doesn't.Copy for heap types — compiler rejects it.