Crate tuple_fn

Source
Expand description

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.

Traitsยง

KnownFnPointer
KnownTuple
TupleFn
Enables the types which implements Fn to be called with arguments tuple.
TupleFnMut
Enables the types which implements FnMut to be called with arguments tuple.
TupleFnOnce
Enables the types which implements FnOnce to be called with arguments tuple.