This is a simple program that demonstrates the basic concepts of Rust programming language.
- Variables
- Data Types
- Functions
- Control Flow
- Error Handling
- Modules
- Structs
- Enums
- Traits
- Generics
- Rust Programming Language
- Cargo Package Manager
- Git
- Code Editor (VS Code, IntelliJ IDEA, etc.)
- Terminal
- Install Rust Programming Language:
# On MacOS and Linux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shFor Windows, refer to the official Rust Installation Guide
- Clone the repository:
git clone https://github.com/TheBlogorithm/learn-rust.git- In Debug mode:
cargo run- In Release mode:
cargo run --release- Rust is a statically typed language. It performs type checking at compile time. Tries to figure out the type of the variable based on the value assigned to it. We can also explicitly specify the type.
- Variables are immutable by default. Use
mutkeyword to make them mutable. - Rust has a concept of ownership. Each value in Rust has a variable that’s called its owner. There can only be one owner at a time. When the owner goes out of scope, the value will be dropped.
- Memory Safety is guaranteed by Rust. It prevents null pointer dereferencing, dangling pointers, buffer overflows, etc.