Loading lesson path
Rust
Rust Tutorial focused on Rust Introduction and related concepts.
Rust is a popular programming language used to build everything from web servers to game engines.
Rust is a modern programming language.
However, if you want to download and install rust, you can go to rust-lang.org and follow the instructions there.
You have already seen the following code a couple of times in the first chapters. Let's break it down to understand it better:
To print text in Rust, you can use the println!() macro:
Comments can be used to explain code, and to make it more readable. It can also be used to prevent execution when testing alternative code.
Variables are containers for storing data values, like numbers and characters.
Unlike many other programming languages, variables in Rust do not need to be declared with a specified type (like "String" for text or "Int" for numbers, if you are familiar with those from C or Java…
Constant variables are used to store values that never change.
Operators are used to perform operations on values and variables.
Very often, in programming, you will need a data type that can only have one of two values, like:
You already know that Rust supports familiar comparison conditions from mathematics, such as:
When you have many choices, using match is easier than writing lots of if...else .
Loops can execute a block of code as long as a specified condition is reached.
The while loop runs as long as a condition is true .
When you know exactly how many times you want to loop through a block of code, use the for loop together with the in keyword, instead of a while loop:
A function is a block of code that only runs when you call it.
Scope refers to where a variable is allowed to be used.
Strings are used to store text.
Rust uses "ownership" to manage memory in a safe way.