How to represent the Boolean "true" and "false" in Rust

1 Answer

0 votes
// In Rust, Boolean values are represented using the built‑in literals:
// true
// false

// The Boolean type is: bool

fn main() {
    let is_active: bool = true;      
    let is_finished: bool = false;  

    println!("is_active = {}", is_active);
    println!("is_finished = {}", is_finished);

    // Boolean expression example
    let result = 10 > 3;
    println!("10 > 3 evaluates to: {}", result);
}


/*
run:

is_active = true
is_finished = false
10 > 3 evaluates to: true

*/

 



answered Apr 15 by avibootz
...