What does “mismatched types: expected `()`” mean when using an if expression?

The problem is that if i % 3 == 0 { "Fizz" } returns either unit () or &'static str. Change the if expressions to return the same type in both cases, for example by adding a else { "" }.

Leave a Comment