3 ms·
Stop caring about writing .clone() until you feel comfortable enough to care. The biggest thing I see people go crazy with in Rust is trying to avoid cloning t
by Klonoar 5y ago
Stop caring about writing .clone() until you feel comfortable enough to care.
The biggest thing I see people go crazy with in Rust is trying to avoid cloning things. I've watched it block people from progressing in the language. Yes, you ultimately don't want to clone everything everywhere, but getting something built in Rust and then iterating backwards is often a better way to learn the language than trying to be "correct" from the start.
Cloning often removes any need to deal with lifetime signatures or what-have-you. If you're bothered by a full clone, grab Rc/Arc and use that trade-off in the beginning - it's not going to kill you. These changes make the syntax of the language fairly comparable to other languages.
tl;dr: .clone() things, measure if it's a problem, and then work backwards to the state you feel that the language/borrow-checker/whatever is pushing you towards.
- metadat 5y agoI appreciate you replying! How does this map a path from zero to proficient?
- Klonoar 5y agoYou're not starting at zero. You have proficiency in other languages and are probably good at them! It's often about getting to a point where you're used to cargo/Rust borrow checker stuff/etc. Removing the lifetime syntax stuff makes it much easier to transpose your existing knowledge and rapidly get up to speed.