Control Flow - The Rust Programming Language
The ability to run some code depending on whether a condition is true and the ability to run some code repeatedly while a condition is true are basic building blocks in most programming languages. The most common constructs that let you control the flow of execution of Rust code are if expressions and loops. An if expression allows you to branch your code depending on conditions. You provide a condition and then state, “If this condition is met, run this block of code. If the condition is not met, do not run this block of code.” Create a new project called branches in your projects directory to explore the if expression. In the src/main.rs file, input the following: Filename: src/main.rs All if expressions start with the keyword if, followed by a condition. In this case, the condition checks whether or not the variable number has a value less than 5. We place the block of code to execute if the condition is true immediately after the condition inside curly brackets. Blocks of code asso
Control Flow - The Rust Programming Language 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 Auto Light Rust Coal Navy Ayu The Rust Programming Language Control Flow The ability to run some code depending on whether a condition is true and the ability to run some code repeatedly while a condition is true are basic building blocks in most programming languages. The most common constructs that let you control the flow of execution of Rust code are if expressions and loops. if Expressions An if e
Explore this link on the map →related reading
- Control Flow - The Rust Programming Languagedoc.rust-lang.org
- The match Control Flow Construct - The Rust Programming Languagedoc.rust-lang.org
- A half-hour to learn Rustfasterthanli.me
- Programming a Guessing Game - The Rust Programming Languagedoc.rust-lang.org
- Control Flow · Crafting Interpreterscraftinginterpreters.com
- Expressions - Rust By Exampledoc.rust-lang.org
- Jumping Back and Forth · Crafting Interpreterscraftinginterpreters.com
- Decide with ifeducative.io
- Control Flow - Circom 2 Documentationdocs.circom.io
- Rust Language Cheat Sheetcheats.rs
- Type Checking If Expressions - journal.stuffwithstuff.comjournal.stuffwithstuff.com
- Functions - The Rust Programming Languagedoc.rust-lang.org