Skip to content

Commit f07aa35

Browse files
committed
Noted that shadowing never destroys a value
1 parent 763f923 commit f07aa35

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
@@ -240,7 +240,10 @@ println!("{}", x); // Prints "42"
240240
Shadowing and mutable bindings may appear as two sides of the same coin, but
241241
they are two distinct concepts that can't always be used interchangeably. For
242242
one, shadowing enables us to rebind a name to a value of a different type. It
243-
is also possible to change the mutability of a binding.
243+
is also possible to change the mutability of a binding. Note that shadowing a
244+
name does not alter or destroy the value it was bound to, and the value will
245+
continue to exist until it goes out of scope, even if it is no longer accessible
246+
by any means.
244247
245248
```rust
246249
let mut x: i32 = 1;

0 commit comments

Comments
 (0)