#tuple #fn #call

tuple-fn

call functions and closures with tuple of arguments

3 stable releases

1.2.0 May 11, 2022
1.1.0 May 10, 2022
1.0.0 Apr 29, 2022

#2703 in Rust patterns

Download history 4/week @ 2024-04-05 18/week @ 2024-05-03 35/week @ 2024-05-10 42/week @ 2024-05-17 52/week @ 2024-05-24 17/week @ 2024-05-31 31/week @ 2024-06-07 305/week @ 2024-06-14 392/week @ 2024-06-21 388/week @ 2024-06-28 398/week @ 2024-07-05 436/week @ 2024-07-12 300/week @ 2024-07-19

1,584 downloads per month

MIT license

17KB
162 lines

tuple-fn

Crates.io docs.rs GitHub license GitHub stars

This crate provides TupleFnOnce, TupleFnMut and TupleFn, corresponding to FnOnce, FnMut and [Fn].

TupleFnOnce, TupleFnMut and TupleFn enables functions or closures to be called with a tuple of arguments. For example:

use tuple_fn::*;

fn add(a: i32, b: i32) -> i32 {
    a + b
}

let sum = add.call_with_args_tuple((1, 2));
assert_eq!(sum, 3);

These three traits should be named as FnOnceCallWithArgsTupleExt, FnMutCallWithArgsTupleExt, FnCallWithArgsTupleExt by convention, because they are implemented for all corresponding FnOnce, FnMut, Fn types and act like extension traits. They are named as TupleFn* just for simplicity.

No runtime deps