Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Boolean

Type name: bool

Rust type: bool

A boolean is a data type that can have one of two values: true or false.

<bool>true</bool>
<bool>yes</bool>
<bool>anything</bool>
<true />

<bool>false</bool>
<bool>no</bool>
<false />

Conversion to other types

When converting a bool to other types, it converts to the following values:

  • int: 1 for true, 0 for false.
  • float: 1.0 for true, 0.0 for false.
  • string: The string representation, which is always true or false.