Char, Bool & Unit
Boolean
- The boolean type is specified using
bool. - Booleans are one byte in size.
fn main() {
// boolean data type inferred
let y = false;
// explicit type annotation
let x: bool = true;
}
Character
- The character type is specified using
char. - Characters are 4 bytes in size.
charis specified with single quotation marks.
fn main() {
// character data type inferred
let c = 'z';
let heart_eyed_cat = '😻';
// with explicit type annotation
let z: char = 'ℤ';
}