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`.
This commit is contained in:
Tobin C. Harding 2022-06-07 15:13:03 +10:00
parent b24a112f08
commit ff8d585c17
1 changed files with 3 additions and 5 deletions

View File

@ -1292,11 +1292,10 @@ mod tests {
fn test_addr_type(payloads: &[Payload], equivalence_classes: &[&[Network]]) { fn test_addr_type(payloads: &[Payload], equivalence_classes: &[&[Network]]) {
for pl in payloads { 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() for valid_net in equivalence_classes.iter()
.filter(|ec| ec.contains(addr_net)) .filter(|ec| ec.contains(addr_net))
.map(|ec| ec.iter()) .flat_map(|ec| ec.iter())
.flatten()
{ {
let addr = Address { let addr = Address {
payload: pl.clone(), payload: pl.clone(),
@ -1307,8 +1306,7 @@ mod tests {
for invalid_net in equivalence_classes.iter() for invalid_net in equivalence_classes.iter()
.filter(|ec| !ec.contains(addr_net)) .filter(|ec| !ec.contains(addr_net))
.map(|ec| ec.iter()) .flat_map(|ec| ec.iter())
.flatten()
{ {
let addr = Address { let addr = Address {
payload: pl.clone(), payload: pl.clone(),