]> git.proxmox.com Git - rustc.git/blob - src/doc/book/listings/ch04-understanding-ownership/no-listing-13-reference-scope-ends/src/main.rs
New upstream version 1.55.0+dfsg1
[rustc.git] / src / doc / book / listings / ch04-understanding-ownership / no-listing-13-reference-scope-ends / src / main.rs
1 fn main() {
2 // ANCHOR: here
3 let mut s = String::from("hello");
4
5 let r1 = &s; // no problem
6 let r2 = &s; // no problem
7 println!("{} and {}", r1, r2);
8 // variables r1 and r2 will not be used after this point
9
10 let r3 = &mut s; // no problem
11 println!("{}", r3);
12 // ANCHOR_END: here
13 }