1pub trait FnOnce<Args> {
2 type Output;
3 fn call_once(self, args: Args) -> Self::Output;
4}
5
6pub trait FnMut<Args>: FnOnce<Args> {
7 fn call_mut(&mut self, args: Args) -> Self::Output;
8}
9
10pub trait Fn<Args>: FnMut<Args> {
11 fn call(&self, args: Args) -> Self::Output;
12}
13
14macro_rules! impl_for_typles {
15 [$(($($i: tt: $ty: ident)*))*] => ($(
16 impl<Func, Ret, $($ty,)*> FnOnce<($($ty,)*)> for Func
17 where
18 Func: core::ops::FnOnce($($ty),*) -> Ret
19 {
20 type Output = Ret;
21 #[inline] fn call_once(self, _args: ($($ty,)*)) -> Self::Output {
22 self($(_args.$i),*)
23 }
24 }
25
26 impl<Func, Ret, $($ty,)*> FnMut<($($ty,)*)> for Func
27 where
28 Func: core::ops::FnMut($($ty),*) -> Ret,
29 {
30 #[inline] fn call_mut(&mut self, _args: ($($ty,)*)) -> Self::Output {
31 self($(_args.$i),*)
32 }
33 }
34
35 impl<Func, Ret, $($ty,)*> Fn<($($ty,)*)> for Func
36 where
37 Func: core::ops::Fn($($ty),*) -> Ret,
38 {
39 #[inline] fn call(&self, _args: ($($ty,)*)) -> Self::Output {
40 self($(_args.$i),*)
41 }
42 }
43 )*);
44}
45
46impl_for_typles!(
47 ()
48 (0: T0)
49 (0: T0 1: T1)
50 (0: T0 1: T1 2: T2)
51 (0: T0 1: T1 2: T2 3: T3)
52 (0: T0 1: T1 2: T2 3: T3 4: T4)
53 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5)
54 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6)
55 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7)
56 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8)
57 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8 9: T9)
58 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8 9: T9 10: T10)
59 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8 9: T9 10: T10 11: T11)
60 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8 9: T9 10: T10 11: T11 12: T12)
61 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8 9: T9 10: T10 11: T11 12: T12 13: T13)
62 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8 9: T9 10: T10 11: T11 12: T12 13: T13 14: T14)
63 (0: T0 1: T1 2: T2 3: T3 4: T4 5: T5 6: T6 7: T7 8: T8 9: T9 10: T10 11: T11 12: T12 13: T13 14: T14 15: T15)
64);