Booleans and characters
Quick answer
Rust's bool type has two values, true and false. Its char type represents one Unicode scalar value, such as a letter or a symbol. Use boolean values for yes/no decisions and character values when one scalar value is needed.
Quotes and Unicode
Use single quotes for a char and double quotes for a string literal. A char occupies four bytes in Rust's representation, even though its UTF-8 encoding can use fewer bytes. One visible symbol may consist of several Unicode scalar values. Boolean values are not interchangeable with integers.
fn main() { let ready: bool = true; let finished: bool = false; println!("Ready: {ready}, finished: {finished}");}Expected stdout (not executed):
Ready: true, finished: falseThe output uses the boolean spellings.
fn main() { let letter: char = 'ر'; let symbol = '✓'; println!("{letter} {symbol}");}Expected stdout (not executed):
ر ✓Both literals represent single scalar values; the source file should use UTF-8.
Common mistake
'ab' is not a valid char literal, and 1 is not a bool. Use a string for multiple scalar values.
Try it yourself
Print a boolean that indicates whether a door is open and a single character representing its label.
Static examples for Rust 1.85.0, edition 2024. Run them locally in a disposable project; ByteMind execution support and these outputs have not been verified.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Booleans and characters — practice quiz
Choose one answer per question, then review the explanation.
Which declaration represents a yes/no state?
How many Unicode scalar values can one Rust char hold?
Which statement about `'✓'` is accurate?