README
This is a Rust macro that implements for comprehensions similar to Scala's.
Example:
let l = map_for!
Will be expanded to:
let l = .map
.filter
.flat_map ;
Note that since Rust does not have an equivalent of Scala's partial
function, the comprehensions can't do full pattern bindings and only
work for single bindings (ie. v <- …) or tuple bindings (ie. (x, y) <- …).
When compared with comp,
map_for is more generic: comp has specialized notation and code
for Option, Iterator and Result and that's it, whereas map_for
will work with any type that has map, flat_map and filter
methods, or that can be extended to have them as map_for.FlatMap and
map_for.Filter do for Option which only has map.
When compared with mdo,
map_for has a simpler and more straightforward approach since most
monadic type will already define the map, flat_map and filter
methods, whereas mdo requires re-implementing a specific API.