403433f2f7
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()`. |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |