Skip to content

Commit 15da6e7

Browse files
authored
Mention size_hint() effect in flat_map_option lint documentation.
1 parent 443f459 commit 15da6e7

File tree

1 file changed

+6
-2
lines changed
  • clippy_lints/src/methods

1 file changed

+6
-2
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,12 @@ declare_clippy_lint! {
231231
/// used instead.
232232
///
233233
/// ### Why is this bad?
234-
/// When applicable, `filter_map()` is more clear since it shows that
235-
/// `Option` is used to produce 0 or 1 items.
234+
/// `filter_map()` is known to always produce 0 or 1 output items per input item,
235+
/// rather than however many the inner iterator type produces.
236+
/// Therefore, it maintains the upper bound in `Iterator::size_hint()`,
237+
/// and communicates to the reader that the input items are not being expanded into
238+
/// multiple output items without their having to notice that the mapping function
239+
/// returns an `Option`.
236240
///
237241
/// ### Example
238242
/// ```no_run

0 commit comments

Comments
 (0)