pub fn lerp<T: std::ops::Mul<T> + std::ops::Add<T>>(a: T, b: T, val: f32) > T {
let safeval = clamp(val, 0.0, 1.0);
a * (1.0  safeval) + b * safeval // interpolate
}
Simple linear interpolation. I'd like this to work for any type that implements
Mul for T * f32 > T
Add for T + T > T.
The above code produces:
 ^^^^^^^^^^^^^^^ expected type parameter `T`, found `f32`

= note: expected type parameter `T`
found type `f32`
which is reasonable. I'm doing a mixedmode multiply. But how do I tell Rust that? I can't find the syntax for that. I tried forms like
Mul<T,f32,Output=T>
but I just get an error telling me that only one type is expected.
I have types of my own that implement multiply by scalar, as below, so I want a generic function that will work on all of them, plus the builtin f32.
/// Multiply by scalar on right
impl ops::Mul<f32> for Vector3 {
type Output = Vector3;
fn mul(self, rhs: f32) > Vector3 {
LLVector3 {
x: self.x * rhs,
y: self.y * rhs,
z: self.z * rhs,
}
}
}