Skip to content

Commit

Permalink
Clarify a detail around move. Fixes #2413.
Browse files Browse the repository at this point in the history
  • Loading branch information
carols10cents committed Jul 25, 2021
1 parent 6c252f2 commit 13b2ee2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ch04-01-what-is-ownership.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,10 @@ safety bugs we mentioned previously. Freeing memory twice can lead to memory
corruption, which can potentially lead to security vulnerabilities.

To ensure memory safety, there’s one more detail to what happens in this
situation in Rust. Instead of trying to copy the allocated memory, Rust
considers `s1` to no longer be valid and, therefore, Rust doesn’t need to free
anything when `s1` goes out of scope. Check out what happens when you try to
use `s1` after `s2` is created; it won’t work:
situation in Rust. After `let s2 = s1`, Rust considers `s1` to no longer be
valid. Therefore, Rust doesn’t need to free anything when `s1` goes out of
scope. Check out what happens when you try to use `s1` after `s2` is created;
it won’t work:

```rust,ignore,does_not_compile
{{#rustdoc_include ../listings/ch04-understanding-ownership/no-listing-04-cant-use-after-move/src/main.rs:here}}
Expand Down

0 comments on commit 13b2ee2

Please sign in to comment.