#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

#2505 in Rust patterns

Download history 420/week @ 2024-07-21 764/week @ 2024-07-28 394/week @ 2024-08-04 537/week @ 2024-08-11 352/week @ 2024-08-18 480/week @ 2024-08-25 491/week @ 2024-09-01 505/week @ 2024-09-08 535/week @ 2024-09-15 234/week @ 2024-09-22 1068/week @ 2024-09-29 1115/week @ 2024-10-06 1038/week @ 2024-10-13 1005/week @ 2024-10-20 1138/week @ 2024-10-27 1136/week @ 2024-11-03

4,463 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