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

Mention all match arms must return same type #4052

Closed

Conversation

jpmelos
Copy link
Contributor

@jpmelos jpmelos commented Oct 1, 2024

I would like to propose that we should mention that all arms of a match expression should return the same type. I believe it should be noted in the section that mentions that match is an expression, and its return value can be bound to variables. The fact that its arms must return the same type is not immediately obvious, but it is possible to argue that it is a very important fact.

I don't know why, but most (all?) internal links have a <!-- ignore --> annotation, so I added one here too... Let me know if I should remove it.

Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I see what you’re going for here. I am going to go ahead and close this one, though, because I think users should be able to figure it out without having it spelled out for them! One thing to note is that we are trying to find ways not to increase the already-long text. Here, the fact that a match returns a value should connect well to the things people already know (including about if expressions and types and values in Rust in general!), so this should be fairly self-evident. If not, the compiler will help!

@chriskrycho chriskrycho closed this Oct 2, 2024
@jpmelos jpmelos deleted the mention-match-arms-same-type-ch-06-02 branch October 2, 2024 13:26
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

Successfully merging this pull request may close these issues.

2 participants