1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-04-22 15:57:46 +02:00

Fix typo in args().next() (#400)

* Fix typo in args().next()

Follow up on #367

* Update match-expressions.md
This commit is contained in:
Charisee Chiw 2023-02-13 13:56:38 -08:00 committed by GitHub
parent faaf2eacdc
commit 2b1dc9ec66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,7 @@ Rust.
* Save the match expression to a variable and print it out. * Save the match expression to a variable and print it out.
* Remove `.as_deref()` and explain the error. * Remove `.as_deref()` and explain the error.
* `std::env::Agrs().next` returns an `Option<&String>`, but we cannot match against `String`. * `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>`. * `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`. * We can now use pattern matching to match against the `&str` inside `Option`.
</details> </details>