why does removing return give me an error: expected '()' but found

Monday, June 30, 2014

I'm writing a quick is_prime function in rust, and I was under the impressed simply writing true was the equivalent of return true;. But this is not the case in my function:

fn is_prime(number: i64) -> bool {
for i in range(2i64, number) {
if number % i == 0 && i != number {

this however will give me the error:

"Error mismatched types: expected `()` but found `bool` (expected () but found bool)

replacing true and false with return true; / return false; works, but why does using the previous not compile?