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

Book: enum comment about match needs more detail #22035

Closed
mdinger opened this issue Feb 7, 2015 · 0 comments · Fixed by #22271
Closed

Book: enum comment about match needs more detail #22035

mdinger opened this issue Feb 7, 2015 · 0 comments · Fixed by #22271

Comments

@mdinger
Copy link
Contributor

mdinger commented Feb 7, 2015

In enum, it was just shown how enum doesn't have equality ops by default among other ops. This should state a (brief) reason why match is useful for many comparison cases (not just that it has pretty branching). I apparently forgot or erased it or something before pushing...

This may seem rather limiting, particularly equality being invalid; in many cases however, it's unnecessary. Rust provides the match keyword, which will be examined in more detail in the next section, which often allows better and easier branch control than a series of if/else statements would. However, for our game we need the comparisons to work so we will utilize the Ordering enum provided by the standard library which supports such comparisons. It has this form:

steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 13, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 13, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 14, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 15, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 15, 2015
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 a pull request may close this issue.

2 participants