You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This'd be a nice ergonomic tweak, an operator in the style of Iterator::filter_map() would be really great. Currently there's a somewhat strange workaround using .flat_map(), e.g.
and while this would functionally be nearly identical, the FilterMap operator could likely specialize somewhat since it only has to handle a single output value
The text was updated successfully, but these errors were encountered:
Implementation-wise yes, filter_map and flat_map are equivalent. However, they do have the semantic difference of "flattening an expanding collection" vs. "removing some items from a collection". It's a very slight thing that tripped me up until I discovered the flat_map pattern, it works but it feels like a slight misuse of impl Iterator for Option, almost like writing for x in Some(thing) {}
This'd be a nice ergonomic tweak, an operator in the style of
Iterator::filter_map()
would be really great. Currently there's a somewhat strange workaround using.flat_map()
, e.g.and while this would functionally be nearly identical, the
FilterMap
operator could likely specialize somewhat since it only has to handle a single output valueThe text was updated successfully, but these errors were encountered: