Deciding whether to run some code based on a condition is an integral part of any programming language. It can be achieved by using if statements and loops.
- Deciding whether to run some code based on a condition…is an integral part of any programming language.…It can be achieved by using if statements and loops.…The most common construct that lets you control…the flow of execution is an if expression.…The else if structure is used if multiple conditions…need to be evaluated, and loops are used…when code has to be repeated multiple times.…Let's create a new project and call it branches.…
So as you can see, the branches file has the src folder.…And let's open up the main.rs file.…As we saw earlier, an if expression allows us…to branch out code depending on condition.…We 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.…Let's declare a variable number with the value five.…We use the let keyword for that.…
So let's write our first if condition.…If a less than 10,…then,…println...…"Condition...…"is true."…And if you can notice, the if block has…an opening curly braces and a closing curly braces.…
- Installing Rust
- Data types
- Adjusting memory allocation
- Setting up race conditions
- Working with functions
- Exploring references and borrowing
- Using structs
- Method syntax
- Demonstrating recoverable errors with Result
- Working with enums
- Getting user input
Skill Level Beginner
Programming Foundations: Data Structures (2014)with Simon Allardice2h 29m Intermediate
1. Hello, Rust!
2. Basic Programming Concepts
3. Ownership in Rust
4. Data Handling and Pattern Matching in Rust
5. Error Handling
6. Sample Rust Project: The Guessing Game
Next steps1m 14s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.