Skip to content

Commit 3ff22cc

Browse files
committed
Rollup merge of #34125 - MichaelNecio:book_addition, r=steveklabnik
Noted that shadowing never destroys a value Fixes issue #33887 r? @steveklabnik
2 parents 814f685 + f07aa35 commit 3ff22cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/doc/book/variable-bindings.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ println!("{}", x); // Prints "42"
241241
Shadowing and mutable bindings may appear as two sides of the same coin, but
242242
they are two distinct concepts that can't always be used interchangeably. For
243243
one, shadowing enables us to rebind a name to a value of a different type. It
244-
is also possible to change the mutability of a binding.
244+
is also possible to change the mutability of a binding. Note that shadowing a
245+
name does not alter or destroy the value it was bound to, and the value will
246+
continue to exist until it goes out of scope, even if it is no longer accessible
247+
by any means.
245248

246249
```rust
247250
let mut x: i32 = 1;

0 commit comments

Comments
 (0)