-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust book-The match Control Flow Construct #4176
Comments
Sorry, I think the original text is fine. For me it is obvious, that (the value) refers in both cases to the first term "resultant value". Your change, using the term "resultant value" three times, makes reading that text very ugly. |
In similar Rust materials, the match pattern is typically compared against the value rather than the resultant value. The specific mention of 'resultant value,' though correct, may sound confusion. Therefore, I suggested consistently to use the term 'value' throughout the text. Anyway, the content is the king not above nitty gritty. |
OK, perhaps you are right. I am not a native English speaker, but had no problem when reading that book one year ago. But still my feeling is, that repeating the same expression "resultant value" three times is ugly. [EDIT] Just read that section and some content again: What do you think about changing "it compares the resultant value against" into "it compares the value after the match keyword against" letting all the other text as it is? |
OK, I hope here is the final solution: When the match expression executes, it compares the expression after the match keyword against the pattern of each arm, in order. If a pattern matches the resultant value, the code associated with that pattern is executed. If that pattern doesn’t match that value, execution continues to the next arm, much as in a coin-sorting machine. Note: I did this editing just as an exercise for myself -- an AI might be still able to find better wordings. |
When the match expression executes, it compares the resultant value against the pattern of each arm, in order. If a pattern matches the value (should be resultant value), the code associated with that pattern is executed. If that pattern doesn’t match the value (should be resultant value), execution continues to the next arm, much as in a coin-sorting machine. We can have as many arms as we need: in Listing 6-3, our match has four arms.
The text was updated successfully, but these errors were encountered: