Skip to content
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

Open
Jit-coder-58 opened this issue Dec 21, 2024 · 4 comments
Open

Rust book-The match Control Flow Construct #4176

Jit-coder-58 opened this issue Dec 21, 2024 · 4 comments

Comments

@Jit-coder-58
Copy link

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.

@StefanSalewski
Copy link

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.

@Jit-coder-58
Copy link
Author

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.

@StefanSalewski
Copy link

StefanSalewski commented Dec 23, 2024

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?

@StefanSalewski
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants