We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 68bad3f + a2f318c commit 6ed2796Copy full SHA for 6ed2796
1 file changed
c-cpp-book/src/ch05-data-structures.md
@@ -71,8 +71,18 @@ fn main() {
71
let b = &a;
72
let c = b;
73
println!("{} {}", *b, *c); // The compiler automatically dereferences *c
74
- // Illegal because b and still are still in scope
75
- // let d = &mut a;
+
+ let d = &mut a;
76
77
+ /*
78
+ * Uncommenting the line below would be cause the
79
+ * program to not compile, because `b` is used
80
+ * while the mutable reference `d` is live in the current scope
81
+ *
82
+ * You cannot have a mutable and immutable reference in use in the same scope
83
+ * at the same time!
84
+ */
85
+ // println!("{}", *b);
86
}
87
let d = &mut a; // Ok: b and c are not in scope
88
*d = 43;
0 commit comments