#pipe #pipeline #function #composition #macro

pipe_macro

A macro to pipe function calls like in functional programming languages

1 unstable release

0.1.0 May 5, 2020

#1118 in Rust patterns

ISC license

5KB
103 lines

pipe_macro

This crate provides a macro to pipe function calls like in some functional programming languages.

Examples

fn add(a: usize, b: usize) -> usize {
    a + b
}

fn double(a: usize) -> usize {
    a * 2
}

let answer = pipe!(
    2
    => double
    => { |n| add(n, 10) }
    => double
);

assert_eq!(answer, 28);
let count = pipe!("https://rust-lang.org" => download.await? => parse? => count_links);

No runtime deps

ֈ^