From 15da6e735a43cd3b49847d4d484d6ec75b33dad6 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Thu, 21 Mar 2024 14:06:45 -0700 Subject: [PATCH] Mention `size_hint()` effect in `flat_map_option` lint documentation. --- clippy_lints/src/methods/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index b6c474212cd..e3137a868a0 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -231,8 +231,12 @@ declare_clippy_lint! { /// used instead. /// /// ### Why is this bad? - /// When applicable, `filter_map()` is more clear since it shows that - /// `Option` is used to produce 0 or 1 items. + /// `filter_map()` is known to always produce 0 or 1 output items per input item, + /// rather than however many the inner iterator type produces. + /// Therefore, it maintains the upper bound in `Iterator::size_hint()`, + /// and communicates to the reader that the input items are not being expanded into + /// multiple output items without their having to notice that the mapping function + /// returns an `Option`. /// /// ### Example /// ```no_run