3 ms·
Rust doesn't have anything for that. Partial move means that if a function only really need to access one field on the struct, it would only take ownership of t
by didibus 7y ago
Rust doesn't have anything for that. Partial move means that if a function only really need to access one field on the struct, it would only take ownership of that field, even though it took the full struct as an argument. So two functions could have ownership of different fields of the struct at the same time.
One thing with Rust is that it is really focused on performance and safety. It also cares about ergonomics, but not over performance and safety. Unfortunately, type explosion does make for faster code that can be validated more easily for safety by the compiler. That said, Rust has good support for vectors, those are used a lot, but are homogeneous. It also supports tuples with nice literal syntax and pattern matching on them. While it favours structs over maps, they are pretty lightweight compared to objects, so very small syntax to define them, you can create one out of another, and have a nice literal syntax to create them. Still, this is not the magical world of dynamic data-structures, so don't try and think you can just map/reduce over your structs and tuples, compose and restructure them freely, print out their content, or merge and split them, etc..
- eternalban 7y agoSo the only thing that is "moving" is the ownership of elements of a structure. It seems "partial move" actually means "partial transfer".
- didibus 7y ago> So the only thing that is "moving" is the ownership of elements of a structure. Yup In rust, you can move, copy or borrow a value. Move - means that the responsibility of freeing the allocated memory is moving to someone else. Rust says the ownership has moved. Copy - means that the full value is copied, and a copy is passed, thus now you have two instances of the value, and each can act independently. Borrow - means that the access permissions to the value are temporarily transferred to something else, but will come back when done, and the responsibility of freeing the memory is still up to the owner (lender). That's why it is called "partial move", cause it's using Rust's terminology. Transfer isn't in the Rust lexicon, so it wouldn't be as appropriate.