1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pub trait HetFnOnce<A> {
type Output;
fn call_once(self, arg: A) -> Self::Output;
}
pub trait HetFnMut<A>: HetFnOnce<A> {
fn call_mut(&mut self, arg: A) -> Self::Output;
}
impl<'a, A, X> HetFnOnce<A> for &'a mut X
where X: HetFnMut<A>
{
type Output = <X as HetFnOnce<A>>::Output;
fn call_once(self, arg: A) -> Self::Output {
X::call_mut(self, arg)
}
}
impl<'a, A, X> HetFnMut<A> for &'a mut X
where X: HetFnMut<A>
{
fn call_mut(&mut self, arg: A) -> Self::Output {
X::call_mut(self, arg)
}
}
pub trait HetFn<A>: HetFnMut<A> {
fn call(&self, arg: A) -> Self::Output;
}
impl<'a, A, X> HetFnOnce<A> for &'a X
where X: HetFn<A>
{
type Output = <X as HetFnOnce<A>>::Output;
fn call_once(self, arg: A) -> Self::Output {
X::call(self, arg)
}
}
impl<'a, A, X> HetFnMut<A> for &'a X
where X: HetFn<A>
{
fn call_mut(&mut self, arg: A) -> Self::Output {
X::call(self, arg)
}
}
impl<'a, A, X> HetFn<A> for &'a X
where X: HetFn<A>
{
fn call(&self, arg: A) -> Self::Output {
X::call(self, arg)
}
}