Concept Flow - Boolean type
Start
Declare bool variable
Assign true or false
Use in condition or print
Program ends
This flow shows how a boolean variable is declared, assigned true or false, then used in conditions or output.
fn main() {
let is_rust_fun: bool = true;
println!("Is Rust fun? {}", is_rust_fun);
}| Step | Action | Variable | Value | Output |
|---|---|---|---|---|
| 1 | Declare variable is_rust_fun | is_rust_fun | uninitialized | |
| 2 | Assign true to is_rust_fun | is_rust_fun | true | |
| 3 | Print is_rust_fun value | is_rust_fun | true | Is Rust fun? true |
| 4 | Program ends |
| Variable | Start | After Step 1 | After Step 2 | Final |
|---|---|---|---|---|
| is_rust_fun | none | uninitialized | true | true |
Boolean type in Rust:
- Declared with 'bool' keyword
- Values: true or false only
- Used in conditions and printing
- Cannot assign numbers directly
- Print with println!("{}", var)