Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
← Certified Rust Programming Expert · Lesson 7 of 7

Module Six

📖 Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
7
Certified Rust Programming Expert – Module Six

Module Six: Professional Rust and Capstone Project – Becoming a Certified Rust Programming Expert

“Certified Rust Programming Expert” – A complete path from beginner to professional

Module Introduction

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!

Learning Objectives

After finishing this module, you will be able to:

  • Organise Rust projects with workspaces and modules.
  • Publish crates to crates.io.
  • Write documentation with rustdoc.
  • Benchmark and tune performance.
  • Review code and follow style guidelines.
  • Apply security best practices.
  • Build a complete capstone project.
  • Prepare for the Certified Rust Programming Expert exam.
  • Complete the course with confidence.

Warm-up Story: Ada Builds a Real Product

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.

Main Lessons

Lesson 1: Project Structure and Workspaces

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:

  1. Create a folder for the workspace.
  2. Add a Cargo.toml with [workspace] and members = [...].
  3. Create each crate inside the workspace folder.
  4. Run 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.

Lesson 2: Publishing Crates to crates.io

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:

  1. Create an account on crates.io.
  2. Get an API token from your account settings.
  3. Run cargo login and paste the token.
  4. Add metadata to Cargo.toml: name, version, authors, description, license.
  5. Write documentation and tests.
  6. Run cargo publish.

Mini summary: Publishing shares your code with the world. Use cargo publish after adding metadata.

Lesson 3: Documentation with rustdoc

Definition: 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:

  1. Use /// for documentation comments.
  2. Write a short description.
  3. Add examples with ```.
  4. Run cargo doc to generate HTML documentation.
  5. Run cargo doc --open to view it.

Mini summary: Documentation comments start with ///. Use cargo doc to generate HTML docs.

Lesson 4: Benchmarking and Performance Tuning

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:

  1. Use std::time::Instant to measure time.
  2. Record Instant::now() before and after.
  3. Use .elapsed() to get the duration.
  4. Use cargo bench for more advanced benchmarking.
  5. Use cargo build --release for optimised builds.

Mini summary: Benchmarking measures speed. Use Instant and cargo bench. Always build with --release for speed.

Lesson 5: Code Review and Style Guidelines

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:

  1. Use cargo fmt to format your code automatically.
  2. Use cargo clippy to catch common mistakes.
  3. Follow Rust’s naming conventions: snake_case for functions, PascalCase for types.
  4. Keep functions small and focused.
  5. Write clear comments.
  6. Review other people’s code politely.

Mini summary: Code review and style guidelines keep code clean. Use cargo fmt and cargo clippy.

Lesson 6: Security Best Practices

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:

  1. Validate all user input.
  2. Use hashing for passwords (e.g., bcrypt, argon2).
  3. Use HTTPS for network communication.
  4. Run cargo audit to check for known vulnerabilities.
  5. Keep dependencies updated.
  6. Avoid unsafe unless necessary.

Mini summary: Security protects your program. Validate input, hash passwords, use HTTPS, and audit dependencies.

Lesson 7: Writing a Library Crate

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:

  1. Run cargo new my_library --lib.
  2. Write public functions in src/lib.rs.
  3. Use pub to make items public.
  4. Add tests in #[cfg(test)].
  5. Use the library in another project by adding it to Cargo.toml.

Mini summary: Library crates are reusable code. Use --lib to create one. Use pub to share functions.

Lesson 8: Writing a Binary Crate

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:

  1. Run cargo new my_program.
  2. Write code in src/main.rs.
  3. Use fn main() as the entry point.
  4. Run with cargo run.
  5. Build with cargo build --release.

Mini summary: Binary crates are runnable programs. Use fn main() as the entry point.

Lesson 9: Using External Crates

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:

  1. Find a crate on crates.io.
  2. Add it to [dependencies] in Cargo.toml.
  3. Run cargo build to download it.
  4. Use it with use crate_name::...;.
  5. Check the crate’s documentation.

Mini summary: External crates save time. Add them to Cargo.toml. Cargo downloads them automatically.

Lesson 10: Writing Good Tests

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:

  1. Use #[cfg(test)] for the test module.
  2. Use #[test] for each test function.
  3. Use assert_eq!, assert!, and assert_ne!.
  4. Test normal, edge, and error cases.
  5. Run with cargo test.

Mini summary: Good tests cover many cases. Use #[test] and run with cargo test.

Lesson 11: Error Handling in Professional Code

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:

  1. Return Result from functions that can fail.
  2. Use ? to propagate errors.
  3. Avoid unwrap in production code.
  4. Use match or if let to handle errors gracefully.
  5. Give clear error messages.

Mini summary: Professional error handling uses Result and Option. Avoid unwrap. Give clear messages.

Lesson 12: Capstone Project – Planning

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:

  1. Choose a project idea.
  2. List the features.
  3. Plan the crates and modules.
  4. Design the data structures.
  5. Write tests for each feature.
  6. Document everything.

Mini summary: Planning is the first step of the capstone. Choose a project, list features, and plan crates.

Lesson 13: Capstone Project – Building

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:

  1. Create the workspace.
  2. Build the library crate first.
  3. Build the binary crate that uses the library.
  4. Write tests for the library.
  5. Write documentation comments.
  6. Run cargo test and cargo clippy.
  7. Fix any issues.

Mini summary: Building the capstone means writing code, tests, and docs. Follow the plan step by step.

Lesson 14: Capstone Project – Finishing and Publishing

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:

  1. Run cargo fmt to format code.
  2. Run cargo clippy to catch issues.
  3. Run cargo test to make sure everything works.
  4. Run cargo doc --open to check documentation.
  5. Run cargo publish to share your library.
  6. Share your project with friends, teachers, and the Rust community.

Mini summary: Finishing means polishing, testing, documenting, and publishing. Share your work with pride.

Lesson 15: Preparing for the Certified Rust Programming Expert Exam

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:

  1. Review Modules One to Five.
  2. Practise coding every day.
  3. Write small projects to test your skills.
  4. Read the official Rust book.
  5. Take practice exams.
  6. Get a good night’s sleep before the exam.
  7. Stay calm and confident.

Mini summary: Prepare by reviewing, practising, and staying calm. You are ready!

Key Vocabulary

WordSimple Definition
WorkspaceA group of related Rust projects.
crates.ioThe official website for sharing Rust crates.
CrateA package of Rust code.
rustdocRust’s documentation tool.
BenchmarkMeasuring how fast code runs.
Performance tuningMaking code faster.
Code reviewChecking code for mistakes and style.
Style guidelinesRules for writing clean code.
SecurityProtecting code and data from attacks.
Library crateReusable code for other programs.
Binary crateA runnable program.
External crateA library written by someone else.
Capstone projectA big project that uses everything you learned.
cargo publishCommand to share your crate.
cargo clippyTool to catch common mistakes.

Important Concepts

  • Workspaces: Group related crates.
  • Publishing: Share your code on crates.io.
  • Documentation: Write clear docs with ///.
  • Benchmarking: Measure and improve speed.
  • Code review: Check code for quality.
  • Security: Validate input, hash passwords, audit dependencies.
  • Library vs binary crates: Reusable code vs runnable programs.
  • External crates: Use other people’s code.
  • Good tests: Cover normal, edge, and error cases.
  • Professional error handling: Use Result, avoid unwrap.
  • Capstone: Plan, build, test, document, publish.

Step-by-step Explanations

How to create a workspace step by step

  1. Create a folder for the workspace.
  2. Add a Cargo.toml with [workspace] and members.
  3. Create each crate inside the workspace.
  4. Run cargo build from the root.

Example:

  [workspace]
  members = ["library", "cli_tool"]
  

How to publish a crate step by step

  1. Create a crates.io account.
  2. Run cargo login with your token.
  3. Add metadata to Cargo.toml.
  4. Write docs and tests.
  5. Run cargo publish.

Example metadata:

  [package]
  name = "my_crate"
  version = "0.1.0"
  authors = ["Ada <ada@example.com>"]
  description = "A helpful Rust library"
  license = "MIT"
  

How to write documentation step by step

  1. Use /// before items.
  2. Write a short description.
  3. Add an example in ```.
  4. Run cargo doc --open.

Example:

  /// Multiplies two numbers.
  ///
  /// # Examples
  ///
  /// ```
  /// assert_eq!(multiply(2, 3), 6);
  /// ```
  pub fn multiply(a: i32, b: i32) -> i32 {
      a * b
  }
  

How to benchmark step by step

  1. Use Instant::now() before and after.
  2. Print .elapsed().
  3. For serious benchmarks, use cargo bench.
  4. Always build with --release.

Example:

  use std::time::Instant;

  let start = Instant::now();
  // work
  println!("{:?}", start.elapsed());
  

Real-life Examples

  • Companies: Use workspaces for big projects.
  • Open source: Publish crates on crates.io.
  • Documentation: Help users understand APIs.
  • Benchmarking: Make software faster.
  • Security: Protect user data.

Nigerian Examples

  • Banking software: Uses workspaces and security best practices.
  • POS systems: Need fast and secure code.
  • School systems: Use library crates for shared logic.
  • Market apps: Publish reusable crates.
  • Nollywood streaming: Uses benchmarking for fast video.

Fun Examples Children Can Relate To

  • Video game: Workspace with graphics, sound, and physics crates.
  • Robot: Library crate for movement, binary for control.
  • Chat app: Publish a library for message handling.
  • School quiz: Benchmark to make questions load fast.
  • Treasure hunt: Security to keep the treasure safe.

Everyday Examples

  • Recipe book: A library crate of recipes.
  • Family calendar: A workspace with different activities.
  • Shopping list: Documented with clear notes.
  • Cooking: Benchmarked for the fastest way.
  • House security: Locks, alarms, and careful checks.

Parent Tips

  • Encourage your child to finish what they start.
  • Let them make mistakes. Errors are learning opportunities.
  • Use everyday examples (recipe book, market) to explain concepts.
  • Set a small daily coding time. Consistency helps.
  • Celebrate small wins, like publishing a crate.
  • Be patient. Professional practices take time.
  • Ask them to teach you what they learned.
  • Keep it fun. Use games and stories.
  • Remind them that even expert programmers keep learning.
  • Encourage them to read the Rust book and join the community.

Interesting Facts

  • Rust’s package manager, Cargo, is one of the most loved tools in programming.
  • crates.io hosts over 100,000 crates.
  • cargo clippy catches hundreds of common mistakes.
  • cargo fmt uses the official Rust style guide.
  • Rust’s documentation tool, rustdoc, can run examples as tests.
  • Rust has a strong security-focused community.
  • Many companies contribute crates to the Rust ecosystem.
  • The Rust book is free and available online.

Did You Know?

  • Did you know that cargo doc --open opens your docs in a browser?
  • Did you know that cargo publish cannot be undone?
  • Did you know that you can have both a library and a binary in one crate?
  • Did you know that cargo audit checks for security vulnerabilities?
  • Did you know that rustdoc examples are tested by cargo test?
  • Did you know that cargo bench uses nightly Rust for advanced benchmarks?
  • Did you know that Rust has a Code of Conduct for its community?
  • Did you know that the Rust compiler is written in Rust?

Remember This

  • Workspaces group related crates.
  • Publish crates with cargo publish.
  • Document with /// and cargo doc.
  • Benchmark with Instant and cargo bench.
  • Review code with cargo fmt and cargo clippy.
  • Secure code with validation, hashing, and audits.
  • Library crates are reusable; binary crates are runnable.
  • External crates save time.
  • Good tests cover many cases.
  • Professional error handling uses Result.
  • Capstone: plan, build, test, document, publish.

Common Mistakes

  • Forgetting metadata before publishing.
  • Not writing documentation.
  • Not testing edge cases.
  • Using unwrap in production code.
  • Ignoring security warnings.
  • Not formatting code with cargo fmt.
  • Not running cargo clippy.
  • Forgetting to update dependencies.
  • Publishing without testing.
  • Ignoring compiler warnings.

Best Practices

  • Use workspaces for big projects.
  • Write docs for every public item.
  • Write tests for every feature.
  • Benchmark before and after changes.
  • Run cargo fmt and cargo clippy often.
  • Validate all input.
  • Hash passwords.
  • Use HTTPS.
  • Audit dependencies with cargo audit.
  • Avoid unsafe unless necessary.
  • Review code with others.
  • Keep learning and reading the Rust book.

Illustrations and Diagrams

Workspace Structure

  my_workspace/
  ├── Cargo.toml
  ├── library/
  │   ├── Cargo.toml
  │   └── src/lib.rs
  └── cli_tool/
      ├── Cargo.toml
      └── src/main.rs
  

Publishing Flow

  Write code
     |
     V
  Write tests
     |
     V
  Write docs
     |
     V
  cargo publish
     |
     V
  crates.io
     |
     V
  Others use your crate
  

Documentation Generation

  Source code with /// comments
        |
        V
  cargo doc
        |
        V
  HTML documentation
        |
        V
  cargo doc --open
        |
        V
  Browser shows docs
  

Benchmarking Timeline

  Start timer
      |
      V
  Run code
      |
      V
  Stop timer
      |
      V
  Print duration
      |
      V
  Optimise code
      |
      V
  Repeat
  

Capstone Project Flow

  Idea
    |
    V
  Plan
    |
    V
  Build
    |
    V
  Test
    |
    V
  Document
    |
    V
  Publish
    |
    V
  Celebrate 🎉
  

Your Learning Journey

  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 🎉
  

Comparison Tables

Library vs Binary Crate

FeatureLibrary CrateBinary Crate
PurposeReusable codeRunnable program
Entry pointlib.rsmain.rs
Use caseShared logicApplications
Commandcargo new --libcargo new

unwrap vs Result

FeatureunwrapResult
SafetyRisky (panics)Safe
Use caseTests, prototypesProduction code
Error handlingNoneFull

Testing vs Benchmarking

FeatureTestingBenchmarking
PurposeCheck correctnessMeasure speed
Toolcargo testcargo bench
OutputPass/failTime taken

Safe vs Unsafe Rust

FeatureSafe RustUnsafe Rust
Memory safetyGuaranteedYou must ensure
Use caseMost programsHardware, FFI
KeywordDefaultunsafe { }

Lesson Summaries

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.

End-of-Module Summary

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!

Frequently Asked Questions

  1. What is a workspace? A group of related Rust projects.
  2. How do I publish a crate? Use cargo publish after adding metadata.
  3. How do I write documentation? Use /// comments and cargo doc.
  4. How do I benchmark? Use Instant or cargo bench.
  5. How do I check my code style? Use cargo fmt and cargo clippy.
  6. How do I secure my code? Validate input, hash passwords, and audit dependencies.
  7. What is the difference between a library and a binary crate? Library is reusable, binary is runnable.
  8. How do I use an external crate? Add it to [dependencies] in Cargo.toml.
  9. What makes a good test? Tests that cover normal, edge, and error cases.
  10. How do I prepare for the exam? Review, practise, and stay calm.

Matching Exercises

Match the word to its definition.

WordDefinition
1. WorkspaceA. Measuring code speed.
2. CrateB. Group of related projects.
3. BenchmarkC. Package of Rust code.
4. rustdocD. Checking code for quality.
5. Code reviewE. Documentation tool.

Answers: 1-B, 2-C, 3-A, 4-E, 5-D

Scenario-based Exercises

  1. Scenario: You have three related crates. What do you use?
    Answer: A workspace.
  2. Scenario: You want to share your library with the world. What do you do?
    Answer: Publish to crates.io.
  3. Scenario: You want to measure how fast your code runs. What do you use?
    Answer: Benchmarking with Instant.
  4. Scenario: You want to catch common mistakes in your code. What do you run?
    Answer: cargo clippy.
  5. Scenario: You want to protect user passwords. What do you do?
    Answer: Hash them with bcrypt or argon2.

Group Activity

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.

Individual Activity

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.

Mini Project

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).

Practical Assignment

Assignment: Create a new Cargo workspace called school_system. Inside, create two crates:

  1. A library crate called school_lib with a Student struct and functions to calculate grades.
  2. A binary crate called school_cli that uses school_lib to print student reports.
  3. Add documentation to the library.
  4. Write tests for the library.
  5. Run cargo test, cargo fmt, and cargo clippy.

Submit: Your workspace folder and screenshots of the program running and tests passing.

Key Takeaways

  • Workspaces group related crates.
  • Publish crates with cargo publish.
  • Document with /// and cargo doc.
  • Benchmark with Instant and cargo bench.
  • Review code with cargo fmt and cargo clippy.
  • Secure code with validation, hashing, and audits.
  • Library crates are reusable; binary crates are runnable.
  • External crates save time.
  • Good tests cover many cases.
  • Professional error handling uses Result.
  • Capstone: plan, build, test, document, publish.
  • Prepare for the exam by reviewing and practising.

Classroom Discussion Questions

  1. Why are workspaces useful for big projects?
  2. Why is documentation important?
  3. How does benchmarking help improve software?
  4. Why is code review important?
  5. What are the most important security practices?
  6. What is the difference between a library and a binary crate?
  7. Why should you avoid unwrap in production code?
  8. What makes a good test?
  9. How do you prepare for a big exam?
  10. What did Ada learn from building her school management system?

Course Conclusion and Next Steps

Congratulations! You have completed all six modules of the Certified Rust Programming Expert course. You have learned:

  • Rust foundations: variables, types, functions, and Cargo.
  • Control flow and ownership: if, match, loops, borrowing, and lifetimes.
  • Custom types and error handling: structs, enums, Option, and Result.
  • Collections, generics, and traits: vectors, hash maps, iterators, closures, and modules.
  • Concurrency and systems programming: threads, channels, Mutex, Arc, files, and command-line tools.
  • Professional Rust: workspaces, publishing, documentation, benchmarking, security, and the capstone project.

What’s next?

  • Take the Certified Rust Programming Expert exam.
  • Build more projects to sharpen your skills.
  • Contribute to open-source Rust projects.
  • Read the official Rust book and other advanced resources.
  • Join the Rust community online and at meetups.
  • Keep learning and never stop asking questions.

You are now a Certified Rust Programming Expert. Go out and build amazing things!

Congratulations! 🎉


End of Module Six – Certified Rust Programming Expert

🏆 Get Certified

🔒

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (₦2,000 or 20,000 coins), and get a verified certificate with your name on it.

🎓 Sign Up to Get Certified
🛠️ Practice Tools
Hands-on simulators & labs - subscription required.
→
🎯 Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
→