Macro rust2fun::pipe

source ·
macro_rules! pipe {
    ($first:expr, $second:expr, $($tail:expr),*) => { ... };
    ($first:expr, $second:expr) => { ... };
    ($single:expr) => { ... };
}
Expand description

Pipe functions.

x |> h |> g |> f = f(g(h(x)))

Example

use rust2fun::prelude::*;

let f = |x| x + 1;
let g = |x| x / 2;
let h = |x| x * 3;

let actual = pipe!(-3, |x: i32| -x, f, g, h);
assert_eq!(6, actual);