If I understand what I am doing, then, if
pub fn mean<I>(it: I) -> f64 where
I: Iterator,
<I as Iterator>::Item: ToPrimitive,
was changed to something like
fn mean<'a, I, T>(x:I)-> f64 where
I: IntoIterator<Item= T>,
T: Into<&'a f64>
{
let it = x.into_iter();
...
}
You could also use mean on vectors. e.g.
as opposed to
mean(vec![1,2,3].iter().collect())
without losing any functionality for iterators themselves. But I am just learning Rust, so I might not understand some limitation of this approach.