Rust Learning is a hands-on repository for practicing Rust fundamentals through small exercises, algorithmic challenges, and Rustlings-style learning modules.
This repository is my Rust learning playground.
It contains two main parts:
- π§ͺ Pool Exercises β small Rust projects focused on logic, strings, arrays, math, and basic algorithms.
- π Rustlings Exercises β guided exercises covering Rust syntax, ownership, borrowing, enums, traits, lifetimes, iterators, smart pointers, threads, macros, and more.
The goal is simple: learn Rust by writing Rust.
This repo covers core Rust concepts such as:
- Variables and mutability
- Functions
- Conditionals
- Primitive types
- Strings and arrays
- Ownership and move semantics
- Structs and enums
- Pattern matching
- Error handling
- Generics
- Traits
- Lifetimes
- Tests
- Iterators
- Smart pointers
- Threads
- Macros
- Clippy
- Type conversions
- Basic algorithms
Rust-Learning-main/
βββ Pool-Exercise/
β βββ poold1/
β β βββ Cargo.toml
β β βββ src/
β β βββ main.rs
β β βββ isneg.rs
β β βββ my_print_alpha.rs
β β βββ print_comb.rs
β β βββ print_comb2.rs
β β βββ print_combn.rs
β β βββ print_digit.rs
β β βββ rev_alpha.rs
β β
β βββ poold2/
β β βββ Cargo.toml
β β βββ src/
β β βββ main.rs
β β βββ get_nbr.rs
β β βββ my_swap.rs
β β βββ putstr.rs
β β βββ rev_str.rs
β β βββ sort_arr.rs
β β βββ str_len.rs
β β
β βββ poold3/
β β βββ Cargo.toml
β β βββ src/
β β βββ main.rs
β β βββ comp_fac_it.rs
β β βββ comp_fac_rec.rs
β β βββ comp_pow_it.rs
β β βββ comp_pow_rec.rs
β β βββ comp_sq_root.rs
β β βββ my_isprime.rs
β β
β βββ poold4/
β βββ Cargo.toml
β βββ src/
β βββ main.rs
β βββ strcmp.rs
β βββ strcpy.rs
β βββ strstr.rs
β
βββ Rustlings/
β βββ exercises/
β βββ 00_intro/
β βββ 01_variables/
β βββ 02_functions/
β βββ 03_if/
β βββ 04_primitive_types/
β βββ 05_vecs/
β βββ 06_move_semantics/
β βββ 07_structs/
β βββ 08_enums/
β βββ 09_strings/
β βββ 10_modules/
β βββ 11_hashmaps/
β βββ 12_options/
β βββ 13_error_handling/
β βββ 14_generics/
β βββ 15_traits/
β βββ 16_lifetimes/
β βββ 17_tests/
β βββ 18_iterators/
β βββ 19_smart_pointers/
β βββ 20_threads/
β βββ 21_macros/
β βββ 22_clippy/
β βββ 23_conversions/
β βββ quizzes/
β
βββ README.mdThe Pool-Exercise folder contains independent Cargo projects split by learning day.
Basic output and number-combination exercises.
Implemented exercises include:
| File | Purpose |
|---|---|
my_print_alpha.rs |
Print the alphabet. |
rev_alpha.rs |
Print the alphabet in reverse. |
print_digit.rs |
Print digits. |
isneg.rs |
Check whether a number is negative. |
print_comb.rs |
Print digit combinations. |
print_comb2.rs |
Print two-number combinations. |
print_combn.rs |
Print combinations of n digits. |
String, array, and pointer-style logic practice.
Implemented exercises include:
| File | Purpose |
|---|---|
putstr.rs |
Print a string. |
str_len.rs |
Get string length. |
rev_str.rs |
Reverse a string. |
my_swap.rs |
Swap values. |
sort_arr.rs |
Sort an array. |
get_nbr.rs |
Convert string input into a number. |
Math and recursion exercises.
Implemented exercises include:
| File | Purpose |
|---|---|
comp_fac_it.rs |
Compute factorial iteratively. |
comp_fac_rec.rs |
Compute factorial recursively. |
comp_pow_it.rs |
Compute power iteratively. |
comp_pow_rec.rs |
Compute power recursively. |
comp_sq_root.rs |
Compute square root. |
my_isprime.rs |
Check prime numbers and find the next prime. |
String comparison and search exercises.
Implemented exercises include:
| File | Purpose |
|---|---|
strcpy.rs |
Copy string behavior. |
strcmp.rs |
Compare strings. |
strstr.rs |
Find a substring inside another string. |
The Rustlings folder contains guided Rust exercises organized by topic.
Covered sections include:
| Section | Topic |
|---|---|
00_intro |
Getting started |
01_variables |
Variables and mutability |
02_functions |
Functions |
03_if |
Conditions |
04_primitive_types |
Primitive types |
05_vecs |
Vectors |
06_move_semantics |
Ownership and moves |
07_structs |
Structs |
08_enums |
Enums |
09_strings |
Strings |
10_modules |
Modules |
11_hashmaps |
HashMaps |
12_options |
Option type |
13_error_handling |
Result and error handling |
14_generics |
Generics |
15_traits |
Traits |
16_lifetimes |
Lifetimes |
17_tests |
Tests |
18_iterators |
Iterators |
19_smart_pointers |
Smart pointers |
20_threads |
Threads |
21_macros |
Macros |
22_clippy |
Clippy checks |
23_conversions |
Type conversions |
quizzes |
Mixed-topic quizzes |
Each pool day is its own Cargo project.
Example:
cd Pool-Exercise/poold1
cargo runRun another day:
cd Pool-Exercise/poold2
cargo runOr:
cd Pool-Exercise/poold3
cargo runOr:
cd Pool-Exercise/poold4
cargo runMake sure Rust is installed:
rustc --version
cargo --versionIf Rust is not installed yet, install it with rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shcargo buildcargo runcargo checkcargo fmtcargo clippyInside poold2, the current main.rs sorts an array:
mod sort_arr;
use sort_arr::sort_arr;
fn main() {
let mut nbs = [2, 1, 4, 2, 5];
let size = nbs.len();
sort_arr(&mut nbs, size);
println!("Sorted {:?}", nbs);
}Expected output:
Sorted [1, 2, 2, 4, 5]The goal of this repository is not to be perfect.
The goal is to improve step by step by building small things, breaking stuff, fixing errors, and getting more comfortable with Rustβs way of thinking.
Current focus:
- Write more Rust every day
- Understand ownership deeply
- Get comfortable with borrowing and lifetimes
- Practice algorithmic thinking
- Use Cargo properly
- Learn how to structure Rust projects cleanly
- Build confidence with compiler errors
Rust is fast, safe, and strict in the best way.
It forces better habits around memory, ownership, types, and error handling while still giving low-level control.
This repository tracks that learning journey.
Built while learning Rust, one compiler error at a time. π¦π₯