summaryrefslogtreecommitdiffstats
path: root/src/doc/book/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc/book/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs')
-rw-r--r--src/doc/book/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs b/src/doc/book/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs
new file mode 100644
index 000000000..0da04c010
--- /dev/null
+++ b/src/doc/book/listings/ch04-understanding-ownership/no-listing-12-immutable-and-mutable-not-allowed/src/main.rs
@@ -0,0 +1,11 @@
+fn main() {
+ // ANCHOR: here
+ let mut s = String::from("hello");
+
+ let r1 = &s; // no problem
+ let r2 = &s; // no problem
+ let r3 = &mut s; // BIG PROBLEM
+
+ println!("{}, {}, and {}", r1, r2, r3);
+ // ANCHOR_END: here
+}