I am implementing a bunch of methods that work on Vecs. I have a trait for them.
The problem is that whereas normally Rust is fairly forgiving about casting Vecs to slices, not so in this context. Some of the methods throw up errors when implemented for Vec<f64>
and yet others when implemented for &[f64].
I got around it by implementing my trait for both Vec<f64>
and for &[f64]. That stopped the errors but, of course, it results in having to write all the method definitions twice.
Is there an idiomatic
solution to this problem that will avoid the duplication?