From ff8d585c176e9522859c3aea8e8148009dbf5dfc Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 7 Jun 2022 15:13:03 +1000 Subject: [PATCH] Use flat_map instead of map().flatten() Clippy emits: warning: called `map(..).flatten()` on `Iterator` As suggested, use `flat_map` instead of chaining `map` with `flatten`. --- src/util/address.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/util/address.rs b/src/util/address.rs index 2c4f9782..a5afaf04 100644 --- a/src/util/address.rs +++ b/src/util/address.rs @@ -1292,11 +1292,10 @@ mod tests { fn test_addr_type(payloads: &[Payload], equivalence_classes: &[&[Network]]) { for pl in payloads { - for addr_net in equivalence_classes.iter().map(|ec| ec.iter()).flatten() { + for addr_net in equivalence_classes.iter().flat_map(|ec| ec.iter()) { for valid_net in equivalence_classes.iter() .filter(|ec| ec.contains(addr_net)) - .map(|ec| ec.iter()) - .flatten() + .flat_map(|ec| ec.iter()) { let addr = Address { payload: pl.clone(), @@ -1307,8 +1306,7 @@ mod tests { for invalid_net in equivalence_classes.iter() .filter(|ec| !ec.contains(addr_net)) - .map(|ec| ec.iter()) - .flatten() + .flat_map(|ec| ec.iter()) { let addr = Address { payload: pl.clone(),