3 ms·
clone() makes an immutable, deep copy/recursive copy of the original data structure. clone() itself makes perfect sense. Why the programmer needed those clone
by urthor 3y ago
clone() makes an immutable, deep copy/recursive copy of the original data structure.
clone() itself makes perfect sense. Why the programmer needed those clones... is a legitimate issue with Rust.
In my experience so far, it's usually to hack around an interaction between the borrow checker and the output of a function constructed using dot syntax.
- dist1ll 3y ago> clone() makes an immutable, deep copy/recursive copy of the original data structure. No. clone() calls std::clone::Clone::clone. For many std collections that means deep/recursive copy. For custom data structures, it can mean anything. It depends entirely on your implementation of the Clone trait.