Skip to content

Files

Latest commit

415c775 · Aug 13, 2022

History

History
This branch is 3 commits ahead of, 2 commits behind fadeevab/design-patterns-rust:main.

prototype

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jul 21, 2022
Aug 13, 2022
Aug 13, 2022

Prototype

Prototype allows cloning objects, even complex ones, without coupling to their specific classes.

Rust has standard Clone implementation (via #[derive(Clone)]) for many types which makes Prototype easy and seamless to use.

let mut circle2 = circle1.clone();

See The Easiest Patterns in Rust.

How to Execute

cargo run --bin prototype

Output

Circle 1: 10, 15, 10
Circle 2: 10, 15, 77