In theory there could be the following implementation:
impl<Input,Output,F> FnMut<Input> for F
where
F: FnOnce(Input) -> Output + Clone
{
extern "rust-call" fn call_mut(&mut self, args: Input) -> Output {
(self.clone())(args)
}
}
impl<Input,Output,F> Fn<Input> for F
where
F: FnOnce(Input) -> Output + Clone
{
extern "rust-call" fn call(&self, args: Input) -> Output {
(self.clone())(args)
}
}
The problem here, is of cause this inevidablely results in conflict implementations. Can specialization solve this problem and then we can put the above in std?