about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-09-06 16:34:43 +0530
committerGitHub <noreply@github.com>2022-09-06 16:34:43 +0530
commit24f998932e1179c16354ad92f2da6204ebcac86e (patch)
treeae0e2927c3f6f1dbd749c7c424a9e8749269fdba /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parent36144f2b3d229a510af02914686a12ae7708265d (diff)
parent33afe9724aff279cd6a9fc1cbbdca5aa8a721e30 (diff)
downloadrust-24f998932e1179c16354ad92f2da6204ebcac86e.tar.gz
rust-24f998932e1179c16354ad92f2da6204ebcac86e.zip
Rollup merge of #101287 - Adam-Gleave:doc_bool_then_some, r=scottmcm
Document eager evaluation of `bool::then_some` argument

I encountered this earlier today and thought maybe `bool::then_some` could use a little addition to the documentation.

It's pretty obvious with familiarity and from looking at the implementation, but the argument for `then_some` is eagerly evaluated, which means if you do the following (as I did), you can have a problem:

```rust
// Oops!
let _ = something
    .has_another_thing()
    .then_some(something.another_thing_or_panic());
```

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)!
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions