Ownership

Ownership is one of the three central pillars in Rust's architecture, where the others are Borrowing and Lifetimes.

In Rust, every single value is always owned by a function. For every value a function owns, it does one of three things to it:


 * Returns it to the parent function
 * Gives ownership to another function
 * Drops it and runs the value's appropriate destructors.

Once ownership is given away, it can't be taken back, and the variable can't be used again (although its name can - see Shadowing).

Types that implement [] (such as  or references) do not have their ownership taken away in the same way that all other types do - instead of taking the ownership away, using that value simply makes a copy of the value (which is essentially free to do) and uses that.