How to create a function that return boolean in Rust

1 Answer

0 votes
fn main() {
     println!("{}", is_divisible(30, 15));
     println!("{}", is_divisible(30, 17));
}

fn is_divisible(a: u32, b: u32) -> bool {
    if b == 0 {
        return false;
    }

    a % b == 0
}





/*
run:

true
false

*/

 



answered May 3, 2023 by avibootz
...