Open spotlesscoder opened 1 month ago
Not moving because I want to use the object after the function call is a dangerous thought. It leads us to think (especially for a beginner) that if I don't want to use the object after such a call, the correct approach would be to move it.
There are explicit reasons to want to move something. As chriskrycho said, reference should be the default, and move should be the exception (if there's a reason).
That was a really good explanation - I think I finally really understood some aspect of the ownership system now. I like your idea.
Maybe we could also add this sentence from your explanation?
In idiomatic Rust, functions do not take ownership of their arguments unless they have a reason to.
because that also wasn't clear to me until you mentioned it
@chriskrycho what's your opinion on that?
In idiomatic Rust, functions do not take ownership of their arguments unless they have a reason to.
I just want to add my voice here that adding this somewhere in the book (I don't know if exactly where this PR is, but somewhere) is very useful. I am reading this book slowly and trying to really grok every concept, and I'm in chapter 16 now, and I don't think this "implicit rule" is mentioned anywhere. I think it's a very good rule and something that should be mentioned explicitly.
That was a really good explanation - I think I finally really understood some aspect of the ownership system now. I like your idea.
Maybe we could also add this sentence from your explanation?
In idiomatic Rust, functions do not take ownership of their arguments unless they have a reason to.
because that also wasn't clear to me until you mentioned it