Crates.io | auto_curry |
lib.rs | auto_curry |
version | 1.0.0 |
source | src |
created_at | 2023-03-24 10:36:41.148198 |
updated_at | 2023-03-30 14:22:19.418531 |
description | Procedural macro to automatically curry functions |
homepage | |
repository | https://github.com/whyrgola/auto_curry |
max_upload_size | |
id | 819173 |
size | 40,305 |
Procedural macro for currying most functions in Rust.
This procedural macro can be thought of as a complete version of
the unfinished Rust library, cutlass
.
add
Example (/examples/add.rs):use auto_curry::curry;
#[curry]
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn main() {
assert_eq!(add(1)(2), 3);
println!("{} = {}", add(1)(2), 3);
}
As of version 0.1.0, the add function in the example above expands exactly to:
fn add(a: i32) -> impl Fn(i32) -> i32 {
move |b| { a + b }
}
As far as I am aware, this is the most performant expansion in stable rust.
impl_trait_in_fn_trait_return
(or alternatively, type_alias_impl_trait
) to be able to significantly
optimize curried functions.