1
0
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:
Andrew Jones 2023-02-16 21:54:18 +00:00 committed by GitHub
parent 5c03394b31
commit 9a4cda6f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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>