Crates.io | tuple-fn |
lib.rs | tuple-fn |
version | 1.2.0 |
source | src |
created_at | 2022-04-29 05:23:00.690529 |
updated_at | 2022-05-11 07:10:59.058933 |
description | call functions and closures with tuple of arguments |
homepage | https://github.com/EqualMa/tuple-fn |
repository | https://github.com/EqualMa/tuple-fn |
max_upload_size | |
id | 577140 |
size | 19,915 |
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.