Skip to content

Commit de4aa3d

Browse files
authored
Update moves-function-calls.md (#220)
Additional note helps to understand what move really means. The `name` ownership went fully into the `say_hello`.
1 parent 8c58253 commit de4aa3d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/ownership/moves-function-calls.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn main() {
1818
<details>
1919

2020
* With the first call to `say_hello`, `main` gives up ownership of `name`. Afterwards, `name` cannot be used anymore within `main`.
21+
* The heap memory allocated for `name` will be freed at the end of the `say_hello` function.
2122
* `main` can retain ownership if it passes `name` as a reference (`&name`) and if `say_hello` accepts a reference as a parameter.
2223
* Alternatively, `main` can pass a clone of `name` in the first call (`name.clone()`).
2324
* Rust makes it harder than C++ to inadvertently create copies by making move semantics the default, and by forcing programmers to make clones explicit.

0 commit comments

Comments
 (0)