An extension trait can do this (playground)
fn main() {
let x = (1, 2);
let y = std::cmp::min.call_with_tuple(x);
println!("{}", y);
let z = i32::default.call_with_tuple(());
println!("{}", z);
}
trait Ext<T> {
type Output;
fn call_with_tuple(self, x: T) -> Self::Output;
}
impl<T, TR> Ext<()> for T
where
T: FnOnce() -> TR,
{
type Output = TR;
fn call_with_tuple(self, _: ()) -> Self::Output {
self()
}
}
impl<T, T0, T1, TR> Ext<(T0, T1)> for T
where
T: FnOnce(T0, T1) -> TR,
{
type Output = TR;
fn call_with_tuple(self, x: (T0, T1)) -> Self::Output {
self(x.0, x.1)
}
}