mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-01-20 21:18:26 +02:00
Update match-expressions.md (#367)
* Update match-expressions.md * Apply suggestions from code review Fine tuning the casing and explanations. --------- Co-authored-by: Martin Geisler <mgeisler@google.com>
This commit is contained in:
parent
36ce63cb10
commit
65340c4ca1
@ -21,3 +21,12 @@ expression of the block, if any. In the example above, the type is `()`.
|
||||
|
||||
See [pattern matching](../pattern-matching.md) for more details on patterns in
|
||||
Rust.
|
||||
|
||||
<details>
|
||||
|
||||
* Save the match expression to a variable and print it out.
|
||||
* Remove `.as_deref()` and explain the error.
|
||||
* `std::env::Agrs().next` returns an `Option<&String>`, but we cannot match against `String`.
|
||||
* `as_deref()` transforms an `Option<T>` to `Option<T::Target>`. In our case, this turns `Option<&String>` into `Option<&str>`.
|
||||
* We can now use pattern matching to match against the `&str` inside `Option`.
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user