diff options
| author | bors <bors@rust-lang.org> | 2024-03-22 13:09:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-22 13:09:28 +0000 |
| commit | 403433f2f7abecb5afb586b1a18fdd44460d1bec (patch) | |
| tree | cd0a33b902732c8af18792f4529062eea096481e /tests/codegen/patchable-function-entry/patchable-function-entry-both-flags.rs | |
| parent | fc053c3296749bbb6fe29af83061c2bfc99d582a (diff) | |
| parent | 15da6e735a43cd3b49847d4d484d6ec75b33dad6 (diff) | |
| download | rust-403433f2f7abecb5afb586b1a18fdd44460d1bec.tar.gz rust-403433f2f7abecb5afb586b1a18fdd44460d1bec.zip | |
Auto merge of #12526 - kpreid:patch-2, r=blyxyas
Mention `size_hint()` effect in `flat_map_option` lint documentation.
The previous documentation for `flat_map_option` mentioned only readability benefits, but there is also at least one performance benefit: the `size_hint()` upper bound is preserved, whereas `flat_map().size_hint()` is always `(0, None)`.
Program demonstrating this difference:
```rust
fn main() {
let evens = |i| if i % 2 == 0 { Some(i) } else { None };
dbg!(
[1, 2, 3].iter().flat_map(evens).size_hint(),
[1, 2, 3].iter().filter_map(evens).size_hint(),
);
}
```
changelog: [`flat_map_option`]: Mention the benefit to `size_hint()`.
Diffstat (limited to 'tests/codegen/patchable-function-entry/patchable-function-entry-both-flags.rs')
0 files changed, 0 insertions, 0 deletions
