Rust Mini Projects — Build Real-World Rust Applications from Scratch
DodaTech
Updated 2026-06-28
1 min read
In this tutorial, you will learn about Rust Mini Projects. We cover key concepts, practical examples, and best practices to help you master this topic.
Rust mini projects build a CLI calculator, file deduplicator, HTTP API server, and markdown parser applying ownership, traits, async, and serde skills.
What You'll Learn
- CLI calculator with clap
- File deduplicator with hashing
- HTTP API with Axum
- Markdown parser
Why It Matters
Projects solidify learning. These patterns appear in ripgrep, fd, bat, and DodaZIP.
Real-World Use
Tool development, file system utilities, Web Services, text processing.
CLI Calculator
use clap::Parser;
#[derive(Parser)]
struct Calc {
a: f64,
op: String,
b: f64,
}
fn main() {
let calc = Calc::parse();
let result = match calc.op.as_str() {
"+" => calc.a + calc.b,
"-" => calc.a - calc.b,
"*" => calc.a * calc.b,
"/" => if calc.b != 0.0 { calc.a / calc.b }
else { panic!("Division by zero") },
_ => panic!("Unknown operator"),
};
println!("{} {} {} = {}", calc.a, calc.op, calc.b, result);
}
File Deduplicator
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use sha2::{Sha256, Digest};
fn file_hash(path: &Path) -> String {
let data = fs::read(path).unwrap();
let mut hasher = Sha256::new();
hasher.update(&data);
format!("{:x}", hasher.finalize())
}
fn find_duplicates(dir: &Path) {
let mut hashes: HashMap<String, Vec<String>> = HashMap::new();
for entry in fs::read_dir(dir).unwrap() {
let entry = entry.unwrap();
if entry.file_type().unwrap().is_file() {
let hash = file_hash(&entry.path());
hashes.entry(hash).or_default()
.push(entry.path().display().to_string());
}
}
for (hash, files) in &hashes {
if files.len() > 1 {
println!("Duplicate ({}): {:?}", hash, files);
}
}
}
fn main() {
find_duplicates(Path::new("."));
}
← Previous
Rust Ecosystem — Community, Frameworks, and Tools for Rust Development
Next →
Rust Deployment — Deploying Rust Applications with Docker, Cross-Compilation, and CI/CD
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro