Crates.io | masala |
lib.rs | masala |
version | 0.2.1 |
source | src |
created_at | 2021-07-24 15:11:40.954518 |
updated_at | 2021-07-29 17:00:51.306747 |
description | Automatic curry. Yum! |
homepage | |
repository | https://github.com/pard68/masala |
max_upload_size | |
id | 426801 |
size | 7,378 |
An autocurrying macro for Rust.
This crate requires nightly:
use masala::curry;
#[curry]
fn mul<T: Multiple>(a: T, b: T) -> T {
a * b
}
#[curry]
fn add<T>(a: Fn(T), b: T, t:T) -> T {
a + b
}
#[curry]
pub fn psi<T: Clone>(a: fn(T, T) -> T, b: fn(T) -> T, c: T, d: T) -> T {
a(b(c.clone()), b(d))
}
fn main() {
let add_10 = add(10);
println!("{}", psi(mul)(add)(10)(3)); // (10 + 10) * (3 + 10) = 33
}