Skip to main content
update url
Source Link
JayXon
  • 789
  • 8
  • 7

Replace all filter_map with flat_map

It works because:

Replace all filter_map with flat_map

It works because:

  • filter_map takes a FnMut(Self::Item) -> Option<B>

  • flat_map takes a FnMut(Self::Item) -> impl IntoIterator

  • Option implements IntoIterator, which will return an iterator with one item for Some and empty iterator for None

Replace all filter_map with flat_map

It works because:

  • filter_map takes a FnMut(Self::Item) -> Option<B>

  • flat_map takes a FnMut(Self::Item) -> impl IntoIterator

  • Option implements IntoIterator, which will return an iterator with one item for Some and empty iterator for None

Source Link
JayXon
  • 789
  • 8
  • 7

Replace all filter_map with flat_map

It works because:

  • filter_map takes a FnMut(Self::Item) -> Option<B>

  • flat_map takes a FnMut(Self::Item) -> impl IntoIterator

  • Option implements IntoIterator, which will return an iterator with one item for Some and empty iterator for None