I have a struct:
pub struct PPSpline<T>
{
k: usize,
t: Vec<f64>,
c: Option<Array1<T>>,
n: usize,
}
which can be constructed with:
pub fn new(k: usize, t: Vec<f64>, c: Option<Vec<T>>) -> Self
When I attempt to construct it as follows I understand why I get a cannot infer type
compilation error:
let pp1 = PPSpline::new(2, vec![1.,1., 2., 2.], None);
So if I try to specify a fully qualified path I get:
let pp1 = PPSpline::f64::new(2, vec![1.,1., 2., 2.], None);
error[E0223]: ambiguous associated type
--> src\splines\spline_f64.rs:403:19
|
403 | let pp2 = PPSpline::f64::new(2, vec![1.,1., 2., 2.], None);
| ^^^^^^^^^^^^^
|
help: if there were a trait named `Example` with associated type `f64` implemented for `spline_f64::PPSpline<_>`, you could use the fully-qualified path
|
403 | let pp2 = <spline_f64::PPSpline<_> as Example>::f64::new(2, vec![1.,1., 2., 2.], None);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I don't understand why this doesn't work and why the compiler has decided to offer confuding help about hypothetical traits that I am not trying to use. How can I re-formulate this to specify the type as f64 directly?
Incidentally should this read "if there was a trait" instead of "if there were a trait"?