Macro hadean::closure [] [src]

macro_rules! closure {
    (__closureargstotuple, $( $closure:tt )*) => { ... };
    (__closureargstotuple_in, ($( $any:tt )*), || $( $closure:tt )*) => { ... };
    (__closureargstotuple_in, ($( $any:tt )*), |$x1:ident: $t1:ty| $( $closure:tt )*) => { ... };
    (__closureargstotuple_in, ($( $any:tt )*), |$x1:ident: $t1:ty, $( $xn:ident: $tn:ty ),*| $( $closure:tt )*) => { ... };
    (__genericboundstotypes_in, ([$( $gtb:tt )*], [$( $x:ident: $t:ty, )*], $( $closure:tt )*), { constr: [$( $dc1:tt )*], params: [$( $dc2:tt )*], ltimes: [$( $dc3:tt )*], tnames: [$( $gt:ident, )*], },) => { ... };
    ([$( $gtb:tt )*], [$( $x:ident: $t:ty ),*], $( $closure:tt )*) => { ... };
    ([$( $x:ident: $t:ty ),*], $( $closure:tt )*) => { ... };
    (_xx, [$( $gt:ident, )*], [$( $gtb:tt )*], [$( $x:ident: $t:ty, )*], $( $closure:tt )*) => { ... };
}

Prepare a closure to be sent over a channel. Looks behaves like Rust closures, but argument types must always be specified, as well as captured variable names and their types.

closure!([capturevar: type, ...], |arg: type, ...| { closurebody ... });Run
fn make_closure() {
    let x: usize = 5;
    let y = 3;
    let s = closure!([x: usize], |y: u8| (x + y as usize));
    s(y);
}Run