Rust Tutorial menu

Rust Tutorial

Rust is a modern programming language that is as fast as C and C++, but much safer. It stops whole groups of bugs, such as crashes from bad memory use, before your program even runs.

For many years developers have voted Rust their most loved language. It is used in web browsers, operating systems, game engines, command-line tools and web servers.

Why Learn Rust?

  • It gives top speed without a garbage collector
  • Its ownership system makes memory errors almost impossible
  • Its compiler gives very helpful error messages
  • Big companies use it for performance-critical work

What You Will Learn

  • Installing Rust and using Cargo
  • Variables, mutability, shadowing and data types
  • if, match and loops
  • Functions and expressions
  • Ownership, borrowing and references
  • Strings, vectors and hash maps
  • Structs, enums, Option and Result

A First Example

Example

rust
fn main() {
    let city = "Karachi";
    let students = 25;
    println!("{} students in {}", students, city);
}
Output
25 students in Karachi

Run the examples on the free Rust Playground at play.rust-lang.org, or install Rust on your computer with rustup.

Exercises and Quiz

Each lesson ends with an exercise, and the last lesson is a quiz on the whole tutorial.

Exercise

What makes Rust different from most fast languages like C?

What to Learn After Rust

Rust is not the easiest first language. If you find it hard, start with Go or Python, then come back. You may also like Bash for working in the terminal.

Want strong programming basics first? The Workownix Python Programming course builds the logic skills that make Rust easier, online or at our institute in Orangi Town, Karachi.

Learn Rust with a teacher

Join the Python Programming course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp