More practical examples for Option::and_then & Result::and_then#93851
More practical examples for Option::and_then & Result::and_then#93851bors merged 8 commits intorust-lang:masterfrom cyqsimon:option-examples
Option::and_then & Result::and_then#93851Conversation
|
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_thenOption::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 |
scottmcm
left a comment
There was a problem hiding this comment.
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_thenis objectively terrible. (No offence to whoever wrote them initially.)Current example:
and_thenconvertsOption<T>toOption<U>So I replaced them with two blocks:
Same thing with
Result::and_then.Hopefully this helps with clarity.