Clone versus move
Quick answer
Use clone() when you deliberately need another value. Cloning a String creates independent owned text, whereas moving it transfers the existing ownership without duplicating the text buffer.
Decide whether two owners are needed
Clone behavior is defined by the type's implementation. For String, cloning copies its contents into separate owned storage; for some other types it can share an underlying resource. Clone is explicit and can allocate or do work. If the original is not needed, a move is simpler.
fn main() { let original = String::from("draft"); let mut copy = original.clone(); copy.push('!'); println!("{original} / {copy}");}Expected stdout (not executed):
draft / draft!Changing the cloned String does not modify the original.
fn main() { let temporary = String::from("ready"); let final_message = temporary; println!("{final_message}");}Expected stdout (not executed):
readyA move is enough because only one owner is needed.
Common mistake
Adding clone to every ownership error may waste memory and hide a better borrowing design.
Try it yourself
Create two independent versions of a note, edit one and print both. Then explain when a move would suffice.
Static examples for Rust 1.85.0, edition 2024. Run them locally in a disposable project; ByteMind execution support and these outputs have not been verified.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Clone versus move — practice quiz
Choose one answer per question, then review the explanation.
Does Clone always mean a deep copy for every Rust type?
After `let b = a.clone()` for a String, what is true?
If you do not need a String after passing it to an owning function, which is simplest?