This commit is contained in:
Carol (Nichols || Goulding)
2017-03-31 16:46:28 -04:00
parent 736cc37390
commit 75d4bc066c

View File

@@ -513,7 +513,9 @@ fn takes_and_gives_back(a_string: String) -> String { // a_string comes into
```
The ownership of a variable follows the same pattern every time: assigning a
value to another variable moves it. When a variable that includes data on the heap goes out of scope, the value will be cleaned up by `drop` unless the data has been moved to be owned by another variable.
value to another variable moves it. When a variable that includes data on the
heap goes out of scope, the value will be cleaned up by `drop` unless the data
has been moved to be owned by another variable.
Taking ownership and then returning ownership with every function is a bit
tedious. What if we want to let a function use a value but not take ownership?