3 ms·
In Haskell you'd use `mapMaybe :: (a -> Maybe b) -> [a] -> [b]`[0], it's a combined map+filter+map specialised for Maybe (option types). Rust has Iterator::filt
by masklinn 10y ago
In Haskell you'd use `mapMaybe :: (a -> Maybe b) -> [a] -> [b]`[0], it's a combined map+filter+map specialised for Maybe (option types). Rust has Iterator::filter_map[1] which does more or less the same thing.
[0] http://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Maybe.html#v:mapMaybe http://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Ma...
[1] https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter_map https://doc.rust-lang.org/std/iter/trait.Iterator.html#metho...