fp-collections 0.0.2

An alternate collections library for rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub fn identity<T>(x: T) -> T {
    x
}

pub fn constant<T: Clone>(x: T) -> impl Fn() -> T {
    move || x.clone()
}

pub fn compose2<T, V, R>(fn1: impl Fn(V) -> R, fn2: impl Fn(T) -> V) -> impl Fn(T) -> R {
    move |x| fn1(fn2(x))
}

#[macro_export]
macro_rules! compose {
    ($x: expr) => ($x);
    ($x: expr, $($xs: expr),+) => (compose2($x, compose!($($xs),+)));
}