2 ms·
Places where I want automatic cloning: 1. Anywhere I call clone(). That should be the default / automatic. 2. Anywhere where I can get copies than explicitly m
by sargun 8y ago
Places where I want automatic cloning:
1. Anywhere I call clone(). That should be the default / automatic.
2. Anywhere where I can get copies than explicitly move for lambdas
The problem with the latter is that I have to call clone outside of the lambda and bind it to a short-lived variable into to get moved to the scope of the lambda.
- burntsushi 8y ago(1) is basically saying "Rust should have copy semantics by default instead of move semantics." I'm very glad that's not the case. Those implicit copies would become easy performance foot guns. In most Rust code I write, using `clone` is fairly uncommon, so it's also optimizing for the wrong thing anyway. Finally, things that aren't cloneable are far more common than things that aren't moveable, so you'd need to smooth out that gap as well. (2) is interesting and I'd be happy to see work done there to make that nicer, but it's hard for me to understand that being a big sticking point.