mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-02-09 12:13:52 +02:00
Fix references within options returned from Args (#427)
This fixes #426
This commit is contained in:
parent
5c03394b31
commit
9a4cda6f35
@ -23,10 +23,10 @@ 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::args().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>`.
|
||||
* `std::env::args().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