Closed Tomer-Eliahu closed 3 months ago
We talked about this in the lang-docs call today. Our feeling overall is there's an interesting question hiding in here about how to describe that the value is moved as part of the call and that the pattern doesn't matter for this.
But at the same time, this PR seems to be build around a mistake -- the idea that the _
is not a wildcard pattern in these circumstances -- so we're going to close it.
Fair enough.
I'll be happy to revise the pull request to point out that while the _
is still a wildcard pattern in function/closure calls, that the value is still moved.
For the explanation as to why that is, I think that reproducing the quote from the Function body documentation in this comment is enough.
The current wildcard pattern documentation has the following as an example of the wildcard pattern:
The problem is that this is not a correct example of the wildcard pattern. The wildcard pattern does not move or copy the value it matches, whereas '_' in closure (or function) parameters does move (or copy) the value. One notable example is the toilet closure:
This pull request fixes and clarifies the documentation. This also closes #848.