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]]) {
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(),