File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
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
+ ```
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ fn main() {
12
12
radius : 10 ,
13
13
} ;
14
14
15
+ // Prototype in action.
15
16
let mut circle2 = circle1. clone ( ) ;
16
17
circle2. radius = 77 ;
17
18
You can’t perform that action at this time.
0 commit comments