A personal, non-official and beginner-friendly repository for learning Rust
If you have never used Rust before, you will probably need to install it in your system
# Install rustup (Rust installer and version management tool)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Source the environment (or restart your terminal)
source ~/.cargo/env
# Verify installation
rustc --version # This is the compiler
cargo --version # This is the build system and package manager (like pip + make)
# Install useful components
rustup component add clippy # Linter for catching common mistakes (normally automatically installed)
rustup component add rustfmt # Code formatter (normally automatically installed)
rustup component add rust-src # Source code for better IDE support
# Optional but recommended: install rust-analyzer for IDE support
# If using VS Code, install the "rust-analyzer" extensionrust-hoex/
├── README.md # Main project documentation
├── LICENSE # MIT License
├── .gitignore # Rust-specific gitignore
├── Cargo.toml # Workspace configuration
├── setup.sh # Environment setup script
├── docs/ # Learning documentation
│ ├── 00-basics.md # Installation and setup guide
│ ├── 01-fundamentals.md # Basic syntax and concepts
│ └── ...
├── examples/ # Standalone example programs
│ ├── 01-helloWorld/
│ ├── 02-variables/
│ ├── 03-functions/
│ └── ...
├── projects/ # Larger tutorial projects
│ ├── cli-utils/ # Command-line applications
│ ├── web-server/ # Basic web server
│ ├── systems/ # Systems programming examples
│ └── algorithms/ # Data structures and algorithms
├── exercises/ # Coding challenges and exercises
│ ├── rustlings/ # Rustlings exercises (if used)
│ ├── advent-of-code/ # Advent of Code solutions
│ └── custom/ # Custom practice problems
├── benchmarks/ # Performance testing examples
├── tests/ # Integration tests
└── utils/ # Development utilities and scripts
├── aliases.sh # Aliases for creation commands
├── creator.sh # Automatic creation of examples, exercises and projects
└── check.sh # Code quality check script- 01-helloWorld: First Rust program
- 02-variables: Variables, mutability, shadowing
- 03-dataTypes: Scalar and compound types
- 04-functions: Function syntax, parameters, return values
- 05-controlFlow: if/else, loops, match
- 06-ownership: Core Rust concept - ownership rules
- 07-borrowing: References and borrowing
- 08-structs: Custom data types
- 09-enums: Enums and pattern matching
- 10-modules: Code organization
- 11-collections: Vec, HashMap, etc.
- 12-error-handling: Result and Option types
- 13-generics: Generic functions and structs
- 14-traits: Defining shared behavior
- 15-lifetimes: Advanced memory management
- 16-testing: Unit and integration tests
- 17-iterators: Functional programming concepts
- 18-closures: Anonymous functions
- 19-smart-pointers: Box, Rc, RefCell
- 20-concurrency: Threads and message passing
- 21-async: Async/await programming
- 22-macros: Metaprogramming
- 23-unsafe: When and how to use unsafe code
- cli-tools: Command-line applications with
clap - web-server: HTTP servers with
axumorwarp - systems: File I/O, network programming
- algorithms: Performance-critical code
- embedded: Basic embedded programming concepts
The root Cargo.toml defines a workspace to manage all sub-projects:
[workspace]
resolver = "2"
members = [
"examples/*/",
# Uncomment these as you create projects/exercises:
# "projects/*/",
# "exercises/*/",
]
[workspace.dependencies]
# Common dependencies used across examples
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1.0", features = ["full"] }
clap = { version = "4.0", features = ["derive"] }
anyhow = "1.0"
thiserror = "1.0"
[workspace.lints.rust]
unsafe_code = "forbid"
[workspace.lints.clippy]
enum_glob_use = "deny"
pedantic = "warn"
nursery = "warn"
unwrap_used = "deny"Each example follows a consistent pattern:
examples/01-helloWorld/
├── Cargo.toml # Project configuration
├── src/
│ └── main.rs # Source code
├── README.md # Example-specific documentation
└── tests/ # Tests (if applicable)
└── integration.rs-
Install Rust (see First steps above)
-
Clone repository:
git clone <repo> && cd rust-hoex -
Run setup:
./setup.sh -
Load aliases permanently: Add this line to your
~/.bashrcor~/.zshrc:source /path/to/your/rust-hoex/utils/aliases.sh
Then restart your terminal or run source ~/.bashrc
# Create a new example
./utils/creator.sh example 01-helloWorld "Hello World program"
# Create a new project
./utils/creator.sh project web-api "Simple REST API with axum"
# Create a new exercise
./utils/creator.sh exercise fizzbuzz "Classic FizzBuzz implementation"After loading aliases, use these convenient commands:
# Module creation
rust-example 01-helloWorld "Hello World program"
rust-project web-api "Simple REST API with axum"
rust-exercise fizzbuzz "Classic FizzBuzz implementation"
# Development tasks
rust-check # Run quality checks (formatting, linting, tests)
rust-test # Run all tests in workspace
rust-build # Build entire workspace
rust-fmt # Format all code
rust-clippy # Run clippy linter on workspaceAfter sourcing utils/aliases.sh, you get these commands:
Module Creation:
rust-create <type> <n> [description]- Generic module creatorrust-example <n> [description]- Create new examplerust-exercise <n> [description]- Create new exerciserust-project <n> [description]- Create new project
Development Tasks:
rust-check- Run quality checks (formatting, linting, tests)rust-test- Run all tests in workspacerust-build- Build entire workspacerust-fmt- Format all coderust-clippy- Run clippy linter on workspace
- Setup: Run
./setup.shto install dependencies - Development: Work in individual example/project directories
- Testing:
cargo testin workspace root runs all tests - Quality:
./utils/check.shruns formatting, linting, and tests - Documentation: Each example includes comprehensive README
- Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - Clone and enter repository:
git clone <repo> && cd rust-hoex - Run setup:
./setup.sh - Create your first example:
./utils/creator.sh example 01-helloWorld "Hello World" - Start coding:
cd examples/01-helloWorld && cargo run
This is a learning repository, but contributions for improvements are welcome! Please ensure all examples:
- Include comprehensive documentation
- Follow Rust best practices
- Include tests where appropriate
- Are beginner-friendly with clear explanations