3 ms·
The function "consumes" the value. Its no longer valid in the function caller's scope. Often the purpose is to consume the value and return a new kind of value
by Waterluvian 7y ago
The function "consumes" the value. Its no longer valid in the function caller's scope.
Often the purpose is to consume the value and return a new kind of value. Maybe `validate_square` takes in `Shape` and returns `Option<Shape>`
If valid or invalid, we have consumed the shape so it cant be reused by accident and can't be used without handling the optional branches.
I'm new so maybe I'm off on this.
- Cyph0n 7y agoIn Rust, this is how “ownership” works. Once a variable is moved to a new scope, ownership moves with it, which means that it cannot be used in the current scope anymore.