2 ms·
> I still don't understand how or why a non-reference is implicitly consumed by passing it (read-only intention) by value(?) to another function and then can't
by throwmeawayjj 8y ago
> I still don't understand how or why a non-reference is implicitly consumed by passing it (read-only intention) by value(?) to another function and then can't be used again.
By default the value is moved in Rust, just like with std::move in C++17, which you say you know. This is to avoid performance issues when you pass complex structures, such as vectors, around. If you want to copy your value, you have to call .copy() explicitly.
- eridius 8y agoWell, .clone()
- sierdolij 8y agoFirst: Grow up throw-away account, you don't need to add FUD know-it-all, jackassism. It's uncivilized and substance-free. You can sign up under a legitimate handle and behave along the intended guidelines, or go somewhere else. That explains the move but not mandating explicit verbosity for a common case. Pony, for example, has consume to end the lifetime of a variable, .