coalesce::coalesce! [] [src]

macro_rules! coalesce {
    (:&mut $i:expr; $t:ident $id:ident $x:expr => $($v:ident)*) => {
        match $i {
            $($crate::$t::$v(ref mut v) => { let $id = v; $x }),*
        }
    };
    (:&$i:expr; $t:ident $id:ident $x:expr => $($v:ident)*) => {
        match $i {
            $($crate::$t::$v(ref v) => { let $id = v; $x }),*
        }
    };
    (:$i:expr; $t:ident $id:ident $x:expr => $($v:ident)*) => {
        match $i {
            $($crate::$t::$v(v) => { let $id = v; $x }),*
        }
    };

    (0 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce0 $id $x => ) };
    (1 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce1 $id $x => A) };
    (2 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce2 $id $x => A B) };
    (3 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce3 $id $x => A B C) };
    (4 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce4 $id $x => A B C D) };
    (5 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce5 $id $x => A B C D E) };
    (6 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce6 $id $x => A B C D E F) };
    (7 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce7 $id $x => A B C D E F G) };
    (8 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce8 $id $x => A B C D E F G H) };
    (9 => |ref mut $id:ident| $x:expr) => { coalesce!(:&mut $id; Coalesce9 $id $x => A B C D E F G H I) };

    (0 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce0 $id $x => ) };
    (1 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce1 $id $x => A) };
    (2 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce2 $id $x => A B) };
    (3 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce3 $id $x => A B C) };
    (4 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce4 $id $x => A B C D) };
    (5 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce5 $id $x => A B C D E) };
    (6 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce6 $id $x => A B C D E F) };
    (7 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce7 $id $x => A B C D E F G) };
    (8 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce8 $id $x => A B C D E F G H) };
    (9 => |ref $id:ident| $x:expr) => { coalesce!(:&$id; Coalesce9 $id $x => A B C D E F G H I) };

    (0 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce0 $id $x => ) };
    (1 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce1 $id $x => A) };
    (2 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce2 $id $x => A B) };
    (3 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce3 $id $x => A B C) };
    (4 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce4 $id $x => A B C D) };
    (5 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce5 $id $x => A B C D E) };
    (6 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce6 $id $x => A B C D E F) };
    (7 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce7 $id $x => A B C D E F G) };
    (8 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce8 $id $x => A B C D E F G H) };
    (9 => |$id:ident| $x:expr) => { coalesce!(:$id; Coalesce9 $id $x => A B C D E F G H I) };
}

Coalesces multiple values into one common (often borrowed) type.

See the crate documentation for an example.