-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More practical examples for Option::and_then
& Result::and_then
#93851
Conversation
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
Thanks for the PR! These look good to me. @bors r+ rollup |
📌 Commit 73a5f01 has been approved by |
Oops. I renamed the branch on GitHub expecting this PR to be unaffected. Sry for any inconvenience. |
I also updated examples for |
Option::and_then
Option::and_then
& Result::and_then
@rustbot author I'm going to mark this as author, so you can continue making additions. Once you're at the final version, use |
My apologies, I really should have made it a draft PR before everything is ready. I will do better next time. Sorry for the disruptions I caused. I'm happy with the current state of this PR and will refrain from making further edits. Thanks. @rustbot ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of thoughts on the Result
examples.
I don't think they're MUSTs, so if you'd rather not make changes then comment and re-ready
the PR.
@rustbot ready |
Thanks for the updates! @bors r+ |
📌 Commit f6f93fd has been approved by |
…askrgr Rollup of 9 pull requests Successful merges: - rust-lang#89926 (make `Instant::{duration_since, elapsed, sub}` saturating and remove workarounds) - rust-lang#90532 (More informative error message for E0015) - rust-lang#93810 (Improve chalk integration) - rust-lang#93851 (More practical examples for `Option::and_then` & `Result::and_then`) - rust-lang#93885 (bootstrap.py: Suggest disabling download-ci-llvm option if url fails to download) - rust-lang#93886 (Stabilise inherent_ascii_escape (FCP in rust-lang#77174)) - rust-lang#93930 (add link to format_args! when mention it in docs) - rust-lang#93936 (Couple of driver cleanups) - rust-lang#93944 (Don't relabel to a team if there is already a team label) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
To be blatantly honest, I think the current example given for
Option::and_then
is objectively terrible. (No offence to whoever wrote them initially.)Current example:
and_then
convertsOption<T>
toOption<U>
So I replaced them with two blocks:
Same thing with
Result::and_then
.Hopefully this helps with clarity.