Intro

The boolean type in Rust is defined with the bool type annotation and can be either a true or false literal.

rust
// Assign `true` to the `stuff` variable
let stuff = true;

// Annotate the `bool` type
let things: bool = false;

Considerations

  • false has a bit battern of 0x00
  • true has a bit battern of 0x01
  • Booleans cannot be used in arithmatic unless they are cast to a u8
# rust