Skip to content

Commit 415c775

Browse files
committed
Prototype: README and comments
1 parent 3a0772c commit 415c775

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

creational/prototype/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Prototype
2+
3+
_**Prototype** allows cloning objects, even complex ones, without coupling to their specific classes._
4+
5+
**_Rust_** has standard `Clone` implementation (via `#[derive(Clone)]`) for many
6+
types which makes Prototype easy and seamless to use.
7+
8+
```rust
9+
let mut circle2 = circle1.clone();
10+
```
11+
12+
See **[The Easiest Patterns in Rust](https://fadeevab.com/the-easiest-patterns-in-rust/)**.
13+
14+
## How to Execute
15+
16+
```bash
17+
cargo run --bin prototype
18+
```
19+
20+
## Output
21+
22+
```
23+
Circle 1: 10, 15, 10
24+
Circle 2: 10, 15, 77
25+
```

creational/prototype/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ fn main() {
1212
radius: 10,
1313
};
1414

15+
// Prototype in action.
1516
let mut circle2 = circle1.clone();
1617
circle2.radius = 77;
1718

0 commit comments

Comments
 (0)