mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-02-08 20:00:30 +02:00
Update destructuring-enums.md (#261)
* Update destructuring-enums.md * Update destructuring-enums.md Following the typesetting and terminology used in https://doc.rust-lang.org/book/ch03-05-control-flow.html and https://doc.rust-lang.org/book/ch06-02-match.html Co-authored-by: Fabian Bornhofen <fbornhofen@google.com>
This commit is contained in:
parent
55fbb23cca
commit
bd3642694b
@ -32,8 +32,8 @@ arm, `half` is bound to the value inside the `Ok` variant. In the second arm,
|
||||
|
||||
<details>
|
||||
|
||||
Consider demonstrating what happens if you add the third enum variant. Rust
|
||||
will try to be helpful and the code won't compile, because you haven't handled
|
||||
the new case in your match statements.
|
||||
Key points:
|
||||
* The `if`/`else` expression is returning an enum that is later unpacked with a `match`.
|
||||
* You can try adding a third variant to the enum definition and displaying the errors when running the code. Point out the places where your code is now inexhaustive and how the compiler trys to give you hints.
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user