4 ms·
"Ownership", "move", "lifetimes", etc have nothing* to do with what happens in the compiled program. It's a kind of static analysis. The closest analogy from th
by ChrisSD 6y ago
"Ownership", "move", "lifetimes", etc have nothing* to do with what happens in the compiled program. It's a kind of static analysis. The closest analogy from the JS world would be what Typescript is to JS. Though that analogy is far from perfect.
If a function "consumes" your owned value that means the value can no longer be used by you. It's swallowed by the function you called. The function may simply drop the value (in which case the memory is likely freed). But it's also able to reuse the underlying buffer or integrate it into another type. Which is where `into_` comes in. It can take the value away from you and give you back another type which is now responsible for managing your original value.
-----
* Note: "nothing" is perhaps a bit too strong but conceptually it helps to think of ownership as its own thing.