mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 20:24:32 -06:00
Match tense and remove more repetition
This commit is contained in:
@@ -637,10 +637,9 @@ match guess.cmp(&secret_number) {
|
|||||||
|
|
||||||
The `cmp()` method compares two values, and can be called on anything that can
|
The `cmp()` method compares two values, and can be called on anything that can
|
||||||
be compared. It takes a reference to the thing you want to compare it to, so
|
be compared. It takes a reference to the thing you want to compare it to, so
|
||||||
here it's comparing our `guess` to our `secret_number` and returning a variant
|
here it's comparing our `guess` to our `secret_number`, and it returns a
|
||||||
of the `Ordering` enum. We use a [`match`][match] statement to decide what to
|
variant of the `Ordering` enum. We use a [`match`][match] statement to decide
|
||||||
do next based on which variant of `Ordering` we got back from our call to
|
what to do next based on which variant of `Ordering` we got back.
|
||||||
`cmp()` with the values in `guess` and `secret_number`.
|
|
||||||
|
|
||||||
[match]: match.html
|
[match]: match.html
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user