Skip to content

Commit a6d36ee

Browse files
committed
feat: refence mutable and immutable ref at a time
1 parent 0e26b6b commit a6d36ee

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

notes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,11 @@
268268

269269
println!("{}, {}", r1, r2);
270270

271+
the same rule applies for mutable and imutable references at a time:
272+
let mut s = String::from("Brendan");
271273

274+
let r1 = &s;
275+
let r2 = &mut s;
272276

273277

274278

projects/ownership/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn main() {
22
let mut s = String::from("Brendan");
33

4-
let r1 = &mut s;
4+
let r1 = &s;
55
let r2 = &mut s;
66

77
println!("{}, {}", r1, r2);

0 commit comments

Comments
 (0)