Re:Rust Ownership Rules
by Cyph0n on Monday March 02, 2020 @08:40AM
(#22464280)
In 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.
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.