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)
}
}