“Certified Rust Programming Expert” – A complete path from beginner to professional
Welcome to the final module, future Rust expert! You have come a long way. In Module One, you learned the basics of Rust. In Module Two, you learned control flow and ownership. In Module Three, you learned custom types and error handling. In Module Four, you learned collections, generics, traits, modules, testing, and debugging. In Module Five, you learned concurrency and systems programming.
Now it is time to become a professional. In this module, we will learn how real Rust developers work. We will learn about project structure and workspaces. We will learn how to publish crates to crates.io. We will learn how to write documentation with rustdoc. We will learn about benchmarking and performance tuning. We will learn code review and style guidelines. We will learn security best practices.
Finally, we will build a capstone project—a complete Rust application that uses everything you have learned. We will also prepare for the Certified Rust Programming Expert exam with practice questions.
By the end of this module, you will be ready to call yourself a Certified Rust Programming Expert. Let’s finish strong!
After finishing this module, you will be able to:
rustdoc.Ada is now a skilled Rust programmer. She has built many small programs: a market price checker, a student report card, a multi-threaded file processor. But now Ada wants to build something bigger. She wants to build a real product that people can use.
Ada decides to build a school management system for schools in Lagos. It will store student records, calculate grades, track attendance, and print reports. It will be a real, complete application.
Ada starts by planning the project. She divides it into parts: a library for data, a command-line tool for teachers, and a web server for parents. She puts each part in its own workspace. This keeps the code clean and easy to manage.
Ada writes documentation for every function, so other programmers can understand her code. She writes tests to make sure everything works. She runs benchmarks to make sure the program is fast. She reviews her code carefully, following style guidelines. She checks for security problems, like making sure passwords are not stored in plain text.
Finally, Ada publishes her library as a crate on crates.io. Now other programmers can use it in their own projects. Ada has become a Certified Rust Programming Expert!
Moral of the story: Professional Rust is about more than writing code. It is about organising projects, documenting, testing, benchmarking, reviewing, and securing your work. With practice, you can do it too.
Definition: A workspace is a group of related Rust projects that share one Cargo.toml and build together.
Why it is important: Big projects need to be organised. Workspaces keep related crates together.
Simple explanation: Think of a school with many classrooms. Each classroom is a crate. The school building is the workspace.
Real-life example: A company with many departments that share one address.
School example: A school with different subjects, all under one principal.
Home example: A house with many rooms, all under one roof.
Nigerian example: A market with many stalls, all under one market association.
Illustration:
my_workspace/
├── Cargo.toml (workspace settings)
├── library/ (crate 1)
│ ├── Cargo.toml
│ └── src/lib.rs
├── cli_tool/ (crate 2)
│ ├── Cargo.toml
│ └── src/main.rs
└── web_server/ (crate 3)
├── Cargo.toml
└── src/main.rs
Step-by-step:
Cargo.toml with [workspace] and members = [...].cargo build from the workspace root to build all crates.Mini summary: Workspaces group related crates. They keep big projects organised and easy to build.
Definition: A crate is a package of Rust code. crates.io is the official website where Rust programmers share crates.
Why it is important: Publishing lets other programmers use your code. It also helps you build a reputation.
Simple explanation: Think of a library. You write a book and put it on the shelf for others to read.
Real-life example: A musician releasing an album for the world to hear.
School example: A student sharing their notes with the whole class.
Home example: A cook sharing their recipe with the neighbourhood.
Nigerian example: A trader selling goods in a big market so everyone can buy.
Illustration:
Your Crate
|
V
cargo publish
|
V
Uploaded to crates.io
|
V
Other programmers can use it
Step-by-step:
cargo login and paste the token.Cargo.toml: name, version, authors, description, license.cargo publish.Mini summary: Publishing shares your code with the world. Use cargo publish after adding metadata.
rustdocDefinition: rustdoc is Rust’s tool for generating documentation from special comments in your code.
Why it is important: Good documentation helps others use your code. It also helps you remember what you wrote.
Simple explanation: Like writing instructions on a machine so anyone can use it.
Real-life example: A manual that comes with a new phone.
School example: A textbook with explanations for every chapter.
Home example: A recipe card with clear steps.
Nigerian example: A signboard that explains how to use a POS machine.
Illustration:
/// Adds two numbers together.
///
/// # Examples
///
/// ```
/// let result = add(2, 3);
/// assert_eq!(result, 5);
/// ```
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
Step-by-step:
/// for documentation comments.```.cargo doc to generate HTML documentation.cargo doc --open to view it.Mini summary: Documentation comments start with ///. Use cargo doc to generate HTML docs.
Definition: Benchmarking means measuring how fast your code runs. Performance tuning means making it faster.
Why it is important: Fast programs are better for users. Rust is already fast, but you can make it faster.
Simple explanation: Like timing how long it takes to run a race, then training to run faster.
Real-life example: A car mechanic tuning an engine for more speed.
School example: Practising maths problems to get faster.
Home example: Finding a faster route to school.
Nigerian example: A trader finding a faster way to serve customers during rush hour.
Illustration:
use std::time::Instant;
fn main() {
let start = Instant::now();
// Code to measure
let mut sum = 0;
for i in 0..1_000_000 {
sum += i;
}
let duration = start.elapsed();
println!("Sum: {}", sum);
println!("Time: {:?}", duration);
}
Step-by-step:
std::time::Instant to measure time.Instant::now() before and after..elapsed() to get the duration.cargo bench for more advanced benchmarking.cargo build --release for optimised builds.Mini summary: Benchmarking measures speed. Use Instant and cargo bench. Always build with --release for speed.
Definition: Code review means checking code for mistakes, clarity, and style. Style guidelines are rules for writing clean code.
Why it is important: Clean code is easier to read, fix, and share.
Simple explanation: Like checking your homework before submitting. Your teacher checks it too.
Real-life example: A newspaper editor checking articles before printing.
School example: A teacher marking your essay for grammar and clarity.
Home example: A parent checking your chores before you go out.
Nigerian example: A market inspector checking that goods are properly displayed and priced.
Illustration:
Code Review Steps: 1. Read the code carefully. 2. Check for mistakes. 3. Check for clarity. 4. Check for style. 5. Suggest improvements. 6. Approve or request changes.
Step-by-step:
cargo fmt to format your code automatically.cargo clippy to catch common mistakes.snake_case for functions, PascalCase for types.Mini summary: Code review and style guidelines keep code clean. Use cargo fmt and cargo clippy.
Definition: Security means protecting your program and data from attacks.
Why it is important: A security bug can expose private data or let attackers control your program.
Simple explanation: Like locking your door at night to keep thieves out.
Real-life example: A bank using strong locks and cameras.
School example: Keeping your exam answers secret.
Home example: Not sharing your house keys with strangers.
Nigerian example: A POS operator checking a customer’s ID before a large transaction.
Illustration:
Security Checklist: +-- Validate all input. +-- Never store passwords in plain text. +-- Use HTTPS for network communication. +-- Keep dependencies updated. +-- Avoid unsafe code unless necessary. +-- Handle errors without leaking information.
Step-by-step:
cargo audit to check for known vulnerabilities.unsafe unless necessary.Mini summary: Security protects your program. Validate input, hash passwords, use HTTPS, and audit dependencies.
Definition: A library crate is a package of reusable code that other programs can use.
Why it is important: Libraries save time. You write code once and use it in many projects.
Simple explanation: Like a toolbox. You keep tools in it and use them whenever you need.
Real-life example: A standard set of screws used in many machines.
School example: A shared formula sheet used in many exams.
Home example: A recipe book used for many meals.
Nigerian example: A standard measure for selling rice in the market.
Illustration:
library/
├── Cargo.toml
└── src/
└── lib.rs (library code)
Step-by-step:
cargo new my_library --lib.src/lib.rs.pub to make items public.#[cfg(test)].Cargo.toml.Mini summary: Library crates are reusable code. Use --lib to create one. Use pub to share functions.
Definition: A binary crate is a program you can run. It has a main function.
Why it is important: Most applications are binary crates.
Simple explanation: Like a finished dish you can serve. The library is the recipe; the binary is the meal.
Real-life example: A car you can drive. The library is the engine parts.
School example: A finished project you submit.
Home example: A cooked meal ready to eat.
Nigerian example: A finished pot of jollof rice ready to serve.
Illustration:
binary/
├── Cargo.toml
└── src/
└── main.rs (program entry)
Step-by-step:
cargo new my_program.src/main.rs.fn main() as the entry point.cargo run.cargo build --release.Mini summary: Binary crates are runnable programs. Use fn main() as the entry point.
Definition: External crates are libraries written by other people. You can use them in your project.
Why it is important: They save you from writing everything from scratch.
Simple explanation: Like buying ingredients from the market instead of growing them yourself.
Real-life example: A builder buying bricks instead of making them.
School example: Using a calculator instead of doing all maths by hand.
Home example: Buying bread instead of baking it.
Nigerian example: A trader buying goods from a wholesaler instead of making them.
Illustration:
[dependencies] serde = "1.0" rand = "0.8"
Step-by-step:
[dependencies] in Cargo.toml.cargo build to download it.use crate_name::...;.Mini summary: External crates save time. Add them to Cargo.toml. Cargo downloads them automatically.
Definition: Tests are code that checks if your code works. Good tests cover many cases.
Why it is important: Tests catch mistakes early and give you confidence.
Simple explanation: Like checking your homework before submitting.
Real-life example: A doctor running many tests before a diagnosis.
School example: A teacher marking many exam papers to be fair.
Home example: Tasting food before serving guests.
Nigerian example: A trader checking goods before selling them.
Illustration:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_add_positive() {
assert_eq!(add(2, 3), 5);
}
#[test]
fn test_add_negative() {
assert_eq!(add(-2, -3), -5);
}
#[test]
fn test_add_zero() {
assert_eq!(add(0, 0), 0);
}
}
Step-by-step:
#[cfg(test)] for the test module.#[test] for each test function.assert_eq!, assert!, and assert_ne!.cargo test.Mini summary: Good tests cover many cases. Use #[test] and run with cargo test.
Definition: Professional error handling means using Result and Option properly, not unwrap.
Why it is important: Programs must not crash unexpectedly.
Simple explanation: Like a driver who checks the road carefully instead of driving blindly.
Real-life example: An ATM that gives a clear message when the card is not valid.
School example: A teacher who explains what went wrong in an exam.
Home example: A parent who explains why you cannot go out.
Nigerian example: A POS operator who tells you exactly why a transaction failed.
Illustration:
fn read_age(s: &str) -> Result{ match s.parse:: () { Ok(age) if age <= 120 => Ok(age), Ok(_) => Err(String::from("Age too high")), Err(_) => Err(String::from("Not a number")), } }
Step-by-step:
Result from functions that can fail.? to propagate errors.unwrap in production code.match or if let to handle errors gracefully.Mini summary: Professional error handling uses Result and Option. Avoid unwrap. Give clear messages.
Definition: A capstone project is a big project that uses everything you learned.
Why it is important: It proves you can build real software.
Simple explanation: Like a final exam where you show everything you know.
Real-life example: A graduation project.
School example: A final year project.
Home example: A big family dinner you prepare alone.
Nigerian example: A trader opening a new shop and managing everything.
Illustration:
Project Idea: School Management System
|
V
Plan: features, crates, data
|
V
Build: library, CLI, tests
|
V
Test: unit, integration
|
V
Document: rustdoc
|
V
Publish: crates.io
|
V
Celebrate 🎉
Step-by-step:
Mini summary: Planning is the first step of the capstone. Choose a project, list features, and plan crates.
Definition: Building the capstone means writing the code, tests, and documentation.
Why it is important: Building is where the real learning happens.
Simple explanation: Like cooking a big meal. You follow the plan step by step.
Real-life example: A builder following a blueprint.
School example: Writing your final year project.
Home example: Cooking a big family dinner.
Nigerian example: A caterer cooking for a wedding.
Illustration:
Step 1: Create workspace
|
V
Step 2: Build library crate
|
V
Step 3: Build CLI crate
|
V
Step 4: Add tests
|
V
Step 5: Add documentation
|
V
Step 6: Run cargo test and cargo clippy
|
V
Step 7: Celebrate 🎉
Step-by-step:
cargo test and cargo clippy.Mini summary: Building the capstone means writing code, tests, and docs. Follow the plan step by step.
Definition: Finishing means polishing the project and publishing it.
Why it is important: A finished project is proof of your skills.
Simple explanation: Like wrapping a gift beautifully before giving it.
Real-life example: A chef plating a dish before serving.
School example: Binding your project neatly before submitting.
Home example: Cleaning the house before guests arrive.
Nigerian example: A trader arranging goods beautifully before opening the stall.
Illustration:
Polish
|
V
Document
|
V
Test
|
V
Publish to crates.io
|
V
Share with friends and teachers
|
V
Celebrate 🎉
Step-by-step:
cargo fmt to format code.cargo clippy to catch issues.cargo test to make sure everything works.cargo doc --open to check documentation.cargo publish to share your library.Mini summary: Finishing means polishing, testing, documenting, and publishing. Share your work with pride.
Definition: The exam tests everything you learned in all six modules.
Why it is important: Passing the exam proves you are a Certified Rust Programming Expert.
Simple explanation: Like a final test after a long course.
Real-life example: A driving test before getting a licence.
School example: A final exam at the end of the year.
Home example: A cooking test before you are allowed to cook alone.
Nigerian example: A trade test before becoming a master trader.
Illustration:
Review all modules
|
V
Practice coding daily
|
V
Write small projects
|
V
Read the Rust book
|
V
Take practice exams
|
V
Pass the exam 🎉
Step-by-step:
Mini summary: Prepare by reviewing, practising, and staying calm. You are ready!
| Word | Simple Definition |
|---|---|
| Workspace | A group of related Rust projects. |
| crates.io | The official website for sharing Rust crates. |
| Crate | A package of Rust code. |
rustdoc | Rust’s documentation tool. |
| Benchmark | Measuring how fast code runs. |
| Performance tuning | Making code faster. |
| Code review | Checking code for mistakes and style. |
| Style guidelines | Rules for writing clean code. |
| Security | Protecting code and data from attacks. |
| Library crate | Reusable code for other programs. |
| Binary crate | A runnable program. |
| External crate | A library written by someone else. |
| Capstone project | A big project that uses everything you learned. |
cargo publish | Command to share your crate. |
cargo clippy | Tool to catch common mistakes. |
///.Result, avoid unwrap.Cargo.toml with [workspace] and members.cargo build from the root.Example:
[workspace] members = ["library", "cli_tool"]
cargo login with your token.Cargo.toml.cargo publish.Example metadata:
[package] name = "my_crate" version = "0.1.0" authors = ["Ada <ada@example.com>"] description = "A helpful Rust library" license = "MIT"
/// before items.```.cargo doc --open.Example:
/// Multiplies two numbers.
///
/// # Examples
///
/// ```
/// assert_eq!(multiply(2, 3), 6);
/// ```
pub fn multiply(a: i32, b: i32) -> i32 {
a * b
}
Instant::now() before and after..elapsed().cargo bench.--release.Example:
use std::time::Instant;
let start = Instant::now();
// work
println!("{:?}", start.elapsed());
cargo clippy catches hundreds of common mistakes.cargo fmt uses the official Rust style guide.cargo doc --open opens your docs in a browser?cargo publish cannot be undone?cargo audit checks for security vulnerabilities?cargo test?cargo bench uses nightly Rust for advanced benchmarks?cargo publish./// and cargo doc.Instant and cargo bench.cargo fmt and cargo clippy.Result.unwrap in production code.cargo fmt.cargo clippy.cargo fmt and cargo clippy often.cargo audit.unsafe unless necessary.
my_workspace/
├── Cargo.toml
├── library/
│ ├── Cargo.toml
│ └── src/lib.rs
└── cli_tool/
├── Cargo.toml
└── src/main.rs
Write code
|
V
Write tests
|
V
Write docs
|
V
cargo publish
|
V
crates.io
|
V
Others use your crate
Source code with /// comments
|
V
cargo doc
|
V
HTML documentation
|
V
cargo doc --open
|
V
Browser shows docs
Start timer
|
V
Run code
|
V
Stop timer
|
V
Print duration
|
V
Optimise code
|
V
Repeat
Idea
|
V
Plan
|
V
Build
|
V
Test
|
V
Document
|
V
Publish
|
V
Celebrate 🎉
Module One: Rust Foundations
|
V
Module Two: Control Flow and Ownership
|
V
Module Three: Custom Types and Error Handling
|
V
Module Four: Collections, Generics, and Traits
|
V
Module Five: Concurrency and Systems Programming
|
V
Module Six: Professional Rust and Capstone
|
V
Certified Rust Programming Expert 🎉
| Feature | Library Crate | Binary Crate |
|---|---|---|
| Purpose | Reusable code | Runnable program |
| Entry point | lib.rs | main.rs |
| Use case | Shared logic | Applications |
| Command | cargo new --lib | cargo new |
| Feature | unwrap | Result |
|---|---|---|
| Safety | Risky (panics) | Safe |
| Use case | Tests, prototypes | Production code |
| Error handling | None | Full |
| Feature | Testing | Benchmarking |
|---|---|---|
| Purpose | Check correctness | Measure speed |
| Tool | cargo test | cargo bench |
| Output | Pass/fail | Time taken |
| Feature | Safe Rust | Unsafe Rust |
|---|---|---|
| Memory safety | Guaranteed | You must ensure |
| Use case | Most programs | Hardware, FFI |
| Keyword | Default | unsafe { } |
Lesson 1: Workspaces group related crates.
Lesson 2: Publish crates to crates.io with cargo publish.
Lesson 3: Document with /// and cargo doc.
Lesson 4: Benchmark with Instant and cargo bench.
Lesson 5: Review code with cargo fmt and cargo clippy.
Lesson 6: Secure code with validation, hashing, and audits.
Lesson 7: Library crates are reusable code.
Lesson 8: Binary crates are runnable programs.
Lesson 9: External crates save time.
Lesson 10: Good tests cover many cases.
Lesson 11: Professional error handling uses Result.
Lesson 12: Plan the capstone project.
Lesson 13: Build the capstone project step by step.
Lesson 14: Polish, document, and publish.
Lesson 15: Prepare for the exam by reviewing and practising.
Congratulations! You have finished Module Six of the Certified Rust Programming Expert course. You learned how to organise big projects with workspaces. You learned how to publish crates to crates.io. You learned how to write documentation with rustdoc. You learned how to benchmark and tune performance. You learned about code review, style guidelines, and security best practices. You learned the difference between library and binary crates. You learned how to use external crates. You learned how to write good tests and handle errors professionally. You planned, built, tested, documented, and published a capstone project. You also prepared for the Certified Rust Programming Expert exam. You are now ready to call yourself a Certified Rust Programming Expert!
cargo publish after adding metadata./// comments and cargo doc.Instant or cargo bench.cargo fmt and cargo clippy.[dependencies] in Cargo.toml.Match the word to its definition.
| Word | Definition |
|---|---|
| 1. Workspace | A. Measuring code speed. |
| 2. Crate | B. Group of related projects. |
| 3. Benchmark | C. Package of Rust code. |
| 4. rustdoc | D. Checking code for quality. |
| 5. Code review | E. Documentation tool. |
Answers: 1-B, 2-C, 3-A, 4-E, 5-D
Instant.cargo clippy.Title: “Plan a Capstone Project”
Instructions: In groups of 3–4, choose a project idea. Plan the workspace, library crate, binary crate, tests, and documentation. Present your plan to the class.
Goal: Practice planning and organisation.
Task: Write a small library crate with two public functions, documentation comments, and tests. Run cargo test and cargo doc --open.
Hint: Use cargo new my_library --lib.
Project: “My First Published Crate”
Create a small library crate that does something useful (e.g., convert temperatures, calculate grades, or format names). Write documentation and tests. Publish it to crates.io (or prepare it for publishing).
Assignment: Create a new Cargo workspace called school_system. Inside, create two crates:
school_lib with a Student struct and functions to calculate grades.school_cli that uses school_lib to print student reports.cargo test, cargo fmt, and cargo clippy.Submit: Your workspace folder and screenshots of the program running and tests passing.
cargo publish./// and cargo doc.Instant and cargo bench.cargo fmt and cargo clippy.Result.unwrap in production code?Congratulations! You have completed all six modules of the Certified Rust Programming Expert course. You have learned:
if, match, loops, borrowing, and lifetimes.Option, and Result.What’s next?
You are now a Certified Rust Programming Expert. Go out and build amazing things!
Congratulations! 🎉
End of Module Six – Certified Rust Programming Expert