auto_curry

Crates.ioauto_curry
lib.rsauto_curry
version1.0.0
sourcesrc
created_at2023-03-24 10:36:41.148198
updated_at2023-03-30 14:22:19.418531
descriptionProcedural macro to automatically curry functions
homepage
repositoryhttps://github.com/whyrgola/auto_curry
max_upload_size
id819173
size40,305
(whyrgola)

documentation

README

auto_curry

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);
}

How it expands:

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.

Capabilities:

  1. Can handle funtions with a self receiver.
  2. Can handle functions with generics and GAT's.
  3. Works on stable.

Known issues:

  • waiting on impl_trait_in_fn_trait_return (or alternatively, type_alias_impl_trait) to be able to significantly optimize curried functions.
Commit count: 8

cargo fmt