From the course: Rust Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Boolean data type and operations

Boolean data type and operations - Rust Tutorial

From the course: Rust Essential Training

Start my 1-month free trial

Boolean data type and operations

- [Instructor] In addition to integer and floating point data types, Rust has another primitive data type called a Boolean which can have one of two possible values either true or false. We can use the same set of logical operators we saw in the previous video to evaluate Boolean values with NOT, AND, OR an XOR. The bit value of one corresponds to true and zero corresponds to false. In fact, if you cast the Boolean data type into an integer the resulting value will be a one or a zero. This example demonstrates those four logical operations applied to the Boolean variables a and b, which are initialized on lines two and three to the values true and false respectively. Lines four, through eight, then display the values of a and b as well as the results of applying the NOT and OR an XOR operations. The NOT operator is represented with an exclamation mark or bang. The AND operator is an ampersand or is a vertical pipe. An…

Contents