Topic
Chars, Bools & Unit Types
Three small types that show up everywhere in Rust.
char holds a single character, bool holds true or false, and () means a function returned nothing.Quick Reference
| Concept | What it means |
|---|---|
| char | A single character, always in single quotes like 'A' |
| bool | Either true or false, nothing in between |
| ! | Flips a bool to its opposite |
| && | True only when both sides are true |
| || | True when either side is true |
| () | The unit type, returned by functions that return nothing |
| Term | What it means | When you use it |
|---|---|---|
| char | A single character, always in single quotes, 4 bytes | Single letters, symbols, emoji |
| bool | Either true or false, 1 byte | Status flags: is_active, is_paid, is_valid |
| ! | NOT operator, flips a bool to its opposite | When you need the opposite of a condition |
| && | AND operator, true only when both sides are true | Requiring multiple conditions to pass together |
| || | OR operator, true when either side is true | Accepting any one of several conditions |
| () | The unit type, holds nothing, size 0 bytes | Return type of functions that do something but return nothing |