I think we should add these impls. They compile and coherence check (in liballoc/boxed.rs).
They add some extra flexibility, for example you should be permitted to use (and return) std::iter::Map<I, Box<FnMut<I::Iter, Output=R>>
if the boxed closure implements the trait itself.
impl<A, R> FnOnce<A> for Box<FnMut<A, Output=R>> {
type Output = R;
extern "rust-call" fn call_once(mut self, args: A) -> R {
(*self).call_mut(args)
}
}
impl<A, R> FnMut<A> for Box<FnMut<A, Output=R>> {
extern "rust-call" fn call_mut(&mut self, args: A) -> R {
(**self).call_mut(args)
}
}
impl<A, R> FnOnce<A> for Box<Fn<A, Output=R>> {
type Output = R;
extern "rust-call" fn call_once(self, args: A) -> R {
(*self).call(args)
}
}
impl<A, R> FnMut<A> for Box<Fn<A, Output=R>> {
extern "rust-call" fn call_mut(&mut self, args: A) -> R {
(**self).call(args)
}
}
impl<A, R> Fn<A> for Box<Fn<A, Output=R>> {
extern "rust-call" fn call(&self, args: A) -> R {
(**self).call(args)
}
}