keyword

Rust true: the affirmative Boolean literal

The literal `true` represents the affirmative Boolean value. Use it for a condition or a flag that is active, enabled or satisfied. Expected output: Notifications on Why: The Boolean value permits the conditional block to execute. Common mistake: The quoted text "true" is a string, not a Boolean.

Formal Syntax & Structure

rust syntaxrust
true

Working Example

Example Snippetrust
fn main() {    let notifications = true;    if notifications {        println!("Notifications on");    }}
Rust Reference