Why should i assign return type twice

⚓ Rust    📅 2025-12-31    👤 surdeus    👁️ 4      

surdeus

I can specify the type of returning value in the add function itself but why is it asking me to assign the type again?

image

impl ops::Add<Complex> for Complex {
    type Output = Complex;

    fn add(self, _rhs: Complex) -> Complex {
        Complex::default()
    }
}

8 posts - 4 participants

Read full topic

🏷️ Rust_feed