For completeness: Another possible place to annotate a type would be the None
, as in:
let pp1 = PPSpline::new(2, vec![1., 1., 2., 2.], None::<Vec<f64>>);
You could also annotate the binding as in
let pp1: PPSpline<f64> = PPSpline::new(2, vec![1., 1., 2., 2.], None);
though given that that’s the original compiler suggestion, you probably wanted to avoid the duplicate PPSpline
. Finally, if you dislike the “::
” of turbofish, it’s also always a possibility to instead wrap the whole type in another layer of <>
bracketing:
let pp1 = <PPSpline<f64>>::new(2, vec![1., 1., 2., 2.], None);
If you on the other hand love turbo fish, ::
is still optionally allowed in types, too.
let pp1 = <PPSpline::<f64>>::new(2, vec![1., 1., 2., 2.], None);
You can even add <>
or ::<>
to parameter-less types; so taken to the extreme, feel free to write
let pp1 = <PPSpline::<f64::<>>>::new(2, vec![1., 1., 2., 2.], Option::<Vec::<f64::<>>>::None::<> {});
to show off your niche Rust syntax knowledge. (These last two examples are a joke; it's valid syntax, but please don't actually do that.)