Closed
Description
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:
Metadata
Metadata
Assignees
Labels
No labels