1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#![no_std]

#![feature(fn_traits)]
#![feature(unboxed_closures)]

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Curry<F>(pub F);

impl<A, F: FnOnce<A>> FnOnce<(A,)> for Curry<F> {
    type Output = F::Output;
    extern "rust-call" fn call_once(self, (a,): (A,)) -> Self::Output { self.0.call_once(a) }
}

impl<A, F: FnMut<A>> FnMut<(A,)> for Curry<F> {
    extern "rust-call" fn call_mut(&mut self, (a,): (A,)) -> Self::Output { self.0.call_mut(a) }
}

impl<A, F: Fn<A>> Fn<(A,)> for Curry<F> {
    extern "rust-call" fn call(&self, (a,): (A,)) -> Self::Output { self.0.call(a) }
}