Closed
Description
The output for the following code is slightly incorrect and shouldn't really point at the value of the return
statement:
fn foo(bar: usize) -> usize {
if bar % 5 == 0 {
return 1;
};
}
fn main() {
println!("Hello, {}!", foo(1))
}
error[E0308]: mismatched types
--> src/main.rs:1:23
|
1 | fn foo(bar: usize) -> usize {
| --- ^^^^^ expected usize, found ()
| |
| this function's body doesn't return
2 | if bar % 5 == 0 {
3 | return 1;
| - expected because of this statement
|
= note: expected type `usize`
found type `()`