Closed
Description
A user provided the following test case that fails compiling at the point where the *
operator is used.
use std::ops::Mul;
#[derive(Copy)]
pub struct S {
a: f64
}
impl Mul<f64> for S {
type Output = S;
fn mul(self, scalar: f64) -> S {
S {
a: self.a * scalar
}
}
}
impl Mul<S> for f64 {
type Output = S;
fn mul(self, s: S) -> S {
s.mul(self)
}
}
fn main() {
let s = S {a: 0f64};
s * 5f64;
5f64 * s; // error: mismatched types: expected `f64`, found `S`
// (expected f64, found struct `S`) [E0308]
}