by Coding_Cat · 11y ago · 0 comments
impl Mul for Vec2{
type Output = double;
fn mul(self, other: Vec2) -> Double {
self.0*other.0+self.1*other.1)
}
}
Although I must admit I'm not (yet) sure why you need to explicitly state the output and define it for the function. But I have only just started with Rust.I generally assume it's because it can't infer the associated type from function signature, for now.