Trait map_for::FlatMap [] [src]

pub trait FlatMap<Item> {
    type Item;
    fn flat_map<U, F>(self, f: F) -> Option<U>
    where
        F: FnOnce(Self::Item) -> Option<U>
; }

This trait creates a flat_map method for Option (equivalent to Option::and_then) so that it can be used in the map_for macro.

Example:

use map_for::FlatMap;
let c = map_for!{
   a <- Some (1);
   b <- Some (2);
   => a+b };
assert_eq!(c, Some (3));

Associated Types

Required Methods

Implementations on Foreign Types

impl<Item> FlatMap<Item> for Option<Item>
[src]

[src]

Implementors