From 1093f7e2325398288f4c1ea116a7b6cfcc5b282f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 24 Apr 2021 19:23:12 -0700 Subject: [PATCH] Resolve flat_map_option pedantic clippy lint error: used `flat_map` where `filter_map` could be used instead --> serde_derive/src/bound.rs:52:10 | 52 | .flat_map(|field| from_field(&field.attrs)) | ^^^^^^^^ help: try: `filter_map` | note: the lint level is defined here --> serde_derive/src/lib.rs:18:22 | 18 | #![deny(clippy::all, clippy::pedantic)] | ^^^^^^^^^^^^^^^^ = note: `#[deny(clippy::flat_map_option)]` implied by `#[deny(clippy::pedantic)]` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_option error: used `flat_map` where `filter_map` could be used instead --> serde_derive/src/bound.rs:74:10 | 74 | .flat_map(|variant| from_variant(&variant.attrs)) | ^^^^^^^^ help: try: `filter_map` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#flat_map_option --- serde_derive/src/bound.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serde_derive/src/bound.rs b/serde_derive/src/bound.rs index 0949dfc5d..6d7402cb4 100644 --- a/serde_derive/src/bound.rs +++ b/serde_derive/src/bound.rs @@ -49,7 +49,7 @@ pub fn with_where_predicates_from_fields( let predicates = cont .data .all_fields() - .flat_map(|field| from_field(&field.attrs)) + .filter_map(|field| from_field(&field.attrs)) .flat_map(|predicates| predicates.to_vec()); let mut generics = generics.clone(); @@ -71,7 +71,7 @@ pub fn with_where_predicates_from_variants( let predicates = variants .iter() - .flat_map(|variant| from_variant(&variant.attrs)) + .filter_map(|variant| from_variant(&variant.attrs)) .flat_map(|predicates| predicates.to_vec()); let mut generics = generics.clone();