partial_application

Crates.iopartial_application
lib.rspartial_application
version0.2.1
sourcesrc
created_at2018-02-26 23:34:51.538568
updated_at2020-07-30 13:58:08.8457
descriptionpartial function application via the partial! macro
homepage
repositoryhttps://github.com/emerentius/partial_application
max_upload_size
id52971
size23,478
(Emerentius)

documentation

https://docs.rs/partial_application

README

partial_application

The partial! macro allows for partial application of a function.

partial!(some_fn => arg0, _, arg2, _) returns the closure |x1, x3| some_fn(arg0, x1, arg2, x3).
Move closures are created by adding move in front of the function: partial!(move ..)

use partial_application::partial;

// When you're using the 2015 edition of Rust, you need to import the macro like this
#[macro_use]
extern crate partial_application;

fn foo(a: i32, b: i32, c: i32, d: i32, mul: i32, off: i32) -> i32 {
    (a + b*b + c.pow(3) + d.pow(4)) * mul - off
}

fn main() {
    let bar = partial!(foo => _, _, 10, 42, 10, 10);
    assert_eq!(
        foo(15, 15, 10, 42, 10, 10),
        bar(15, 15)
    );
}
Commit count: 10

cargo fmt