3 ms·
Yeah, I don't really understand what the OP is trying to say there other than "I'm frustrated." The lack of examples makes it hard to know. Passing by value wor
by burntsushi 8y ago
Yeah, I don't really understand what the OP is trying to say there other than "I'm frustrated." The lack of examples makes it hard to know. Passing by value works just fine in Rust, so it's hard to unpack what the author was getting at.
- macintux 8y agoI'd guess he's referring to this. https://internals.rust-lang.org/t/why-do-i-have-to-indicate-pass-by-simple-reference-or-by-value-in-calling-code/991 https://internals.rust-lang.org/t/why-do-i-have-to-indicate-...
- burntsushi 8y agoYeah, still doesn't make any sense to me. That request is asking for implicit references (a small syntactical change as far as I can tell), which is different from what you asked for and doesn't seem to match up with what the OP wants either. Without examples or further clarification, I don't think it's possible to understand what the OP actually meant.
- sargun 8y agoPlaces 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.