I am trying to implement a trait `ODE`

for all types `F: Fn(&f64) -> f64`

, so that I can define an integration on named functions and also closures. While my implementation works quite well for named functions, I get quite complex errors for boxed closures:

```
the trait bound `for<'r> std::boxed::Box<for<'r> std::ops::Fn(&'r f64) -> f64>: std::ops::Fn<(&'r f64,)>` is not satisfied
```

This can be reproduced with this code example on playpen: https://is.gd/Adx4bt

Can somebody explain to me what exactly the error here is? How do I go about fixing this?

Playpen code also copied below.

```
struct Euler<S, T> {
dt: f64,
system: S,
temp: T,
}
impl<S,T> Euler<S,T>
where S: ODE<State=T>,
T: Clone,
{
pub fn new(mut system: S, dt: f64, state: &T) -> Self {
let temp = system.differentiate(&state);
Euler {
dt: dt,
system: system,
temp: temp,
}
}
}
pub trait ODE {
type State: Clone;
fn differentiate_into(&mut self, &Self::State, &mut Self::State);
fn differentiate(&mut self, state: &Self::State) -> Self::State {
let mut derivative = state.clone();
self.differentiate_into(state, &mut derivative);
derivative
}
}
impl<F> ODE for F
where F: Fn(&f64) -> f64,
{
type State = f64;
fn differentiate_into(&mut self, state: &Self::State, derivative: &mut Self::State) {
*derivative = self(state);
}
}
fn main() {
fn fn_system(x: &f64) -> f64 {
1.0 * x
}
let a = 1.0;
let closure_system: Box<Fn(&f64) -> f64> = Box::new(|x: &f64| { a * x});
let mut x = 1.0;
let timestep = 0.1;
// // Named functions work!
// let mut stepper = Euler::new(fn_system, timestep, &x);
let mut stepper = Euler::new(closure_system, timestep, &x);
}
```