partial-bind 0.1.0

A simple proc-macro library that provides a macro to partial bind function arguments using closures.
Documentation
  • Coverage
  • 50%
    1 out of 2 items documented1 out of 1 items with examples
  • Size
  • Source code size: 5.97 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 275.12 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 5s Average build duration of successful builds.
  • all releases: 5s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ZXY595/partial-bind
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ZXY595

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