Macro ea::chain [−][src]
macro_rules! chain { ($function: ident($($params: expr),*)) => { ... }; (|$($c_params: ident),*| $body: block($($expr: expr),*)) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*)) => { ... }; (move |$($c_params: ident),*| $body: block($($expr: expr),*)) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*)) => { ... }; (&|$($c_params: ident),*| $body: block($(*$expr: expr),*)) => { ... }; ((&|$($c_params: ident),*| $body: expr)($($expr: expr),*)) => { ... }; (& mut |$($c_params: ident),*| $body: block($($expr: expr),*)) => { ... }; ((& mut |$($c_params: ident),*| $body: expr)($($expr: expr),*)) => { ... }; ($function: ident($($params: expr),*), $function2: ident) => { ... }; ($function: ident($($params: expr),*), |$c_params: ident| $body: expr) => { ... }; ($function: ident($($params: expr),*), |$c_params: ident: $ty: ident| $body: expr) => { ... }; ($function: ident($($params: expr),*), |$c_params: ident: & $ty: ident| $body: expr) => { ... }; ($function: ident($($params: expr),*), |$c_params: ident: & mut $ty: ident| $body: tt) => { ... }; ($function: ident($($params: expr),*), move |$c_params: ident| $body: tt) => { ... }; ($function: ident($($params: expr),*), move |$c_params: ident: $ty: ident| $body: tt) => { ... }; ($function: ident($($params: expr),*), move |$c_params: ident: & $ty: ident| $body: tt) => { ... }; ($function: ident($($params: expr),*), move |$c_params: ident: & mut $ty: ident| $body: tt) => { ... }; ($function: ident($($params: expr),*), $function2: ident, $($more_func: ident),+) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), $func: ident) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), $func: ident) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), |$($c2_params: ident),*| $body2: expr) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), $func: ident) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($expr: expr), $func: ident) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$c2_params: ident| $body2: expr) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$c2_params: ident| $body2: expr) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_params: ident| $body2: expr) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_params: ident| $body2: expr) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_params: ident: $ty: ty| $body2: expr) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_params: ident: $ty: ty| $body2: expr) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$c2_params: ident: $ty: ty| $body2: expr) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$c2_params: ident: $ty: ty| $body2: expr) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_params: ident: $ty2: ty| $body2: expr) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_params: ident: $ty2: ty| $body2: expr) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_params: ident: $ty2: ty| $body2: expr) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_params: ident: $ty2: ty| $body2: expr) => { ... }; ($function: ident($($params: expr),*), |$c_params: ident| $body: expr, $($other: tt)*) => { ... }; ($function: ident($($params: expr),*), move |$c_params: ident| $body: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), $function: ident, $($other: tt)*) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), $function: ident, $($other: tt)*) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), |$($c2_params: ident),*| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), |$($c2_params: ident),*| $body2: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$c2_params: ident| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$($c2_params: ident),*| $body2: expr, $($other: tt)*) => { ... }; ($function: ident($($params: expr),*), |$c_params: ident: $ty: ty| $body: expr, $($other: tt)*) => { ... }; ($function: ident($($params: expr),*), move |$c_params: ident: $ty: ty| $body: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), $function: ident, $($other: tt)*) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), $function: ident, $($other: tt)*) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_params: ident| $body2: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_params: ident| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_params: ident| $body2: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident),*| $body: expr)($($expr: expr),*), move |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; ((|$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; ((move |$($c_params: ident: $ty: ty),*| $body: expr)($($expr: expr),*), move |$c2_param: ident: $ty2: ty| $body2: expr, $($other: tt)*) => { ... }; }
A macro counterpart of function chain which reduce verbosity and defer the execution until entire chain is formed.
This macro will expanded to a nested function call, not a (Chainable)[struct.Chainable.html] struct.
For example:
use ea::chain; let result = chain!((|a, b, c| a + b + c)(1i32, 2, 3), |d| d * 2); assert_eq!(12, result); // The macro will expand into something like this assert_eq!( 12, (|d| d * 2)((|a, b, c| a + b + c)(1i32, 2, 3)) );
Another example using function:
use ea::chain; fn function(a : i32, b : i32, c : i32) -> i32{ a + b + c } fn subsequence_function(d: i32) -> i32 { d * 2 } let outer = 2; let result = chain!( function(1, 2, 3), |e| e + 1, move |f| f * outer, subsequence_function, subsequence_function); assert_eq!(56, result); // This macro will be expanded to: assert_eq!(56, subsequence_function( subsequence_function( (move |f| f * outer)( (|e| e + 1)( function(1, 2, 3) ) ) ) ) )