Rust Conditional Expressions

A conditional expression is used to specify a block of code that executes when a specific condition is met.

Conditional expressions allow programmers to use basic logical functionality in their code. If the condition is true, then the code executes. If the condition is false then the code block is skipped.

Rust has a few types of conditional expressions:

  • if
  • match
  • if let

    Conditional expressions are one of the two primary types of flow control, the other being loops.