primitive-type

Rust bool: Boolean values

A bool stores one of two logical values: true or false. Comparisons produce Boolean values, making bool useful for decisions and flags. Expected output: true Why: Four is greater than zero. Common mistake: Do not use integers as Boolean conditions.

Formal Syntax & Structure

rust syntaxrust
let name: bool = true;

Working Example

Example Snippetrust
fn main() {    let seats = 4;    let has_room: bool = seats > 0;    println!("{has_room}");}
Rust Reference