Skip to content

Latest commit

 

History

History
165 lines (112 loc) · 4.68 KB

rust-programming-notes.md

File metadata and controls

165 lines (112 loc) · 4.68 KB

Rust For Undergrads Free Course - Udemy

A deep dive into basics of Rust programming language.

Table of Contents

Section 1: Introduction

Overview

  • Rust is a systems programming language sponsored by Mozilla which describes it as a "safe, concurrent, practical language", supporting functional and imperative-procedural paradigms.

  • Rust is syntactically similar to C++, but its designers intend it to provide better memory safety while still maintaining performance prevents segfaults, and guarantees thread safety.

Prerequisites

  • Basic programming experience
  • Beginning Programmers
  • Advanced Programmers
  • Basics Concepts: OOP, ...

Section 2: Installatiion

  • Click on the following link to go to the official installation website: https://www.rust-lang.org/tools/install
  • Based on the OS you're using the website assistant will provide you with the installation guide for your machine.

Update Rust packages & toolchain (after the installation):

  • rustup: The Rust toolchain installer
  • cargo: Rust's package manager
  • rustc; Rust compiler

Toolchain update + Cargo:

rustup update

Section 3: Hello World with Rust

Hello World!

fn main() {
    println!("Hello, world!");
}

Compile:

rustc .\hello_world.rs

Execute:

\hello_world\hello_world.exe

Hello World using Cargo

Why?

  • Complex Rust programs need dependencies

Automate your compilation process with cargo:

  • Cargo - the build system and package manager of rust
    • build the code
    • download libraries your code depends on (dependencies)

To create cargo project execute the command below:

cargo new my_cargo_project --bin

output:

Created binary (application) `my_cargo_project` package

To build & run the project:

cargo build

Then,

cargo run

if any error:

rustc --explain E0382

Where E0382 is the error id

Quiz

Section 4: Basics Concepts

Section 5: Ownership with Rust

Section 6: Data Handling and Pattern Matching in Rust

Section 7: Error Handling

Section 8: Conclusion

References

Some of functionalities that Rust std Libraries(Colletion of Crates)/Modules/Packages covers:

- Core language features: The standard library provides the basic building blocks of the Rust language, such as integers, floats, strings, and booleans.
- Data structures: The standard library provides a variety of data structures, such as vectors, maps, and sets.
- IO: The standard library provides functions for reading and writing data to and from the filesystem, network sockets, and other sources.
- Concurrency: The standard library provides primitives for writing concurrent code, such as threads, mutexes, and condition variables.
- Error handling: The standard library provides a mechanism for handling errors, such as the Result type.