The Programming basics
In this chapter we'll explore some basic programming concepts that are not exclusive to Rust, rather they are available in almost all programming languages such as declaring variables.
We are going to explore these concepts and how to implement them in Rust. We'll cover the following topics:
Variables
We'll learn how to declare variables in Rust, and how to make them mutable. We'll also learn about shadowing, which is a unique feature of Rust. We'll also learn about the const
keyword and how to declare global variables.
Data types
We'll explore the basic data types in Rust, such as integers, floating-point numbers, booleans, characters, and strings.
Functions
We'll learn how to define functions in Rust, and how to pass arguments to functions, what are statements and expressions and how to return values from functions.
Comments
We'll learn how to write comments in Rust, and how to use them to document our code.
Control flow
We'll learn about control flow statements in Rust, such as if
expressions, loop
expressions, while
loops, and for
loops.
Number guessing game project
Finally, we'll put all of these concepts together to build a simple number guessing game which will be the first project in this guide that will demonstrate all of the concepts we learned up to this point.
By the end of this chapter, you'll have a good understanding of the basic programming concepts in Rust, and you'll be ready to move on to more advanced topics.
In the first lesson of this chapter, we'll learn about variables in Rust. Let's get started!