Skip to content

Glossary: Software Design Patterns in Rust

Clone

Also written: clone(), #[derive(Clone)]

A trait whose `clone()` makes an independent copy of a value, field by field. The prototype pattern uses it, and it should be used for a real second owner, not to silence the borrow checker.

Where the book teaches it

Related terms

PrototypeStruct update syntaxBorrow checker