Document eager evaluation of bool::then_some argument#101287
Document eager evaluation of bool::then_some argument#101287bors merged 2 commits intorust-lang:masterfrom
bool::then_some argument#101287Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @scottmcm (or someone else) soon. Please see the contribution instructions for more information. |
|
This looks like essentially the same phrasing as is used on https://doc.rust-lang.org/std/option/enum.Option.html#method.map_or, so it makes sense to me. Thanks! @bors r+ rollup @Adam-Gleave Consider also suggesting a clippy lint for this, like there is for https://rust-lang.github.io/rust-clippy/master/index.html#or_fun_call |
Brilliant, thanks! Good idea, a clippy lint would be nice to have. |
Rollup of 5 pull requests Successful merges: - rust-lang#100658 (TyCtxt::get_attr should check that no duplicates are allowed) - rust-lang#101021 (Migrate ``rustc_middle`` diagnostic) - rust-lang#101287 (Document eager evaluation of `bool::then_some` argument) - rust-lang#101412 (Some more cleanup in `core`) - rust-lang#101427 (Fix ICE, generalize 'move generics to trait' suggestion for >0 non-rcvr arguments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
I encountered this earlier today and thought maybe
bool::then_somecould use a little addition to the documentation.It's pretty obvious with familiarity and from looking at the implementation, but the argument for
then_someis eagerly evaluated, which means if you do the following (as I did), you can have a problem:A note, similar to other methods with eagerly-evaluated arguments and a lazy alternative (
Option::or, for example), could help point this out to people who forget (like me)!