]> git.lizzy.rs Git - rust.git/commitdiff
Noted that shadowing never destroys a value
authorMichael Necio <MichaelNecio@users.noreply.github.com>
Mon, 6 Jun 2016 22:13:20 +0000 (18:13 -0400)
committerMichael Necio <MichaelNecio@users.noreply.github.com>
Mon, 6 Jun 2016 22:13:20 +0000 (18:13 -0400)
src/doc/book/variable-bindings.md

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