partial-bind

Crates.iopartial-bind
lib.rspartial-bind
version0.1.0
created_at2025-08-30 19:22:18.611886+00
updated_at2025-08-30 19:22:18.611886+00
descriptionA simple proc-macro library that provides a macro to partial bind function arguments using closures.
homepage
repositoryhttps://github.com/ZXY595/partial-bind
max_upload_size
id1817889
size6,489
ZXY (ZXY595)

documentation

README

Rust Partial Bind

A simple proc-macro library that provides a macro to partial bind function arguments using closures. Which is known as partial function application.

Syntax:

bind!(foo(1, 2, _, _, 3)); // which generates: |__1, __2| foo(1, 2, __1, __2, 3)

Usage:

Case: Add context for api handler in web backend:

let (tx, rx) = async_channel::unbounded();

tokio::spawn(async move {tx.send(1).await.unwrap()});

router.route("/api/1", get(bind!(handler(rx))))

async fn handler(rx: async_channel::Receiver<i32>) -> i32 {
    rx.recv().await.unwrap()
}
Commit count: 3

cargo fmt