3 ms·
>Rust can work this way, but mostly doesn't by default. It's like you were programming in C++ but instead of normal copies and references, almost every single v
by coderenegade 4y ago
>Rust can work this way, but mostly doesn't by default. It's like you were programming in C++ but instead of normal copies and references, almost every single variable use was a std::move. Profoundly unintuitive. I just used this variable, why can't I use it again?!
This was my experience of rust as well. I've since forgotten exactly what I was trying to do (it was a year ago now), but a seemingly innocuous check of the variable I was using meant I couldn't use it immediately afterwards. I have no issues with move semantics in C++, but making that the default behavior in rust made it a pain in the ass to use, especially when it doesn't seem to be consistent. I ended up rewriting a week's worth of rust in C++, including the unit tests, over two days.
- cmrdporcupine 4y agoYeah to be clear I'm not opposed to the semantics of how Rust manages lifetimes. I'm ... disturbed.. by the syntax. It feels "bolted on". Variable assignments and usages that borrow should be clear with a different syntax. Lifetimes should not be lumped in the same box with other type parameters but instead broken out visually into some other sort of annotation on the type. BTW I also think "std::move" in C++ is a hack. They should have introduced a new syntactical element for that as well instead of masquerading it underneath a pseudo-function.