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

Module One

📖 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.
2
Certified Rust Programming Expert – Module One

Module One: Rust Foundations – Your First Steps to Becoming a Certified Rust Expert

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

Module Introduction

Hello, future Rust expert! Have you ever wondered how computers run games, send messages, and keep your money safe in banks? The answer is systems programming. And the best language for systems programming today is Rust.

Rust is a language used by big companies like Microsoft, Google, Amazon, and even space agencies. It is fast, safe, and helps you build programs that do not crash easily. But do not worry—Rust is also fun and friendly for beginners. This module will start from the very beginning.

In this first module, we will learn what Rust is, why it is special, how to install it, and how to write your very first programs. We will use simple words, fun stories, and lots of examples from Nigeria and around the world. By the end, you will understand the heart of Rust and be ready to continue your journey to becoming a Certified Rust Programming Expert.

No prior coding experience is needed. Just bring your curiosity and a willingness to learn!

Learning Objectives

After finishing this module, you will be able to:

  • Explain what systems programming is and why it matters.
  • Describe what Rust is and why it is special.
  • Install Rust and Cargo on your computer.
  • Write and run your first Rust program.
  • Use variables and understand data types.
  • Understand mutability and why Rust values safety.
  • Write functions and use comments.
  • Print output and read input from the user.
  • Recognize common mistakes and best practices.
  • Complete a mini project and practical assignment.

Warm-up Story: Ada and the Amazing Robot

Once upon a time in Lagos, Nigeria, there lived a clever girl named Ada. Ada loved building things. One day, she built a small robot named Chidi. Chidi could walk, talk, and even fetch water. But there was a big problem: Chidi kept crashing into walls! Every time Ada gave Chidi a command, Chidi would get confused and fall down.

Ada asked her friend, Tunde, who was a computer whiz. Tunde said, “Ada, the problem is not Chidi’s body. It is Chidi’s brain. The instructions inside Chidi are not safe. The computer language you used lets Chidi make mistakes that the computer cannot catch. You need a language that checks your work before the robot moves.”

Ada was curious. “Which language can do that?” she asked. Tunde smiled and said, “Rust! Rust is like a careful teacher. It checks every instruction before the robot runs. It stops mistakes that could make Chidi crash. With Rust, Chidi can walk safely and never bump into walls again.”

Ada decided to learn Rust. She read books, watched videos, and practised every day. Slowly, Chidi became the smartest robot in Lagos. Chidi could walk, stop, turn, and even greet people without falling. Ada was so proud!

Today, Ada is a Certified Rust Programming Expert. She builds robots, apps, and systems for companies all over the world. And it all started with one decision: to learn Rust.

Moral of the story: Rust helps you write code that is safe and correct, so your programs (or robots!) do not break easily. With practice, you can become an expert too.

Main Lessons

Lesson 1: What is Systems Programming?

Definition: Systems programming is writing software that controls the computer’s hardware and makes other programs run. It is like being the engineer who builds the roads and bridges that other cars (apps) drive on.

Why it is important: Without systems programming, your computer would not know how to turn on, save files, or connect to the internet.

Simple explanation: Imagine your computer is a big city. Systems programs are the roads, traffic lights, and water pipes. They keep everything moving. Apps like games and browsers are the cars and houses that use those roads.

Real-life example: The operating system (like Windows, macOS, or Linux) is a systems program. It manages your keyboard, screen, and memory.

School example: The school timetable is like a systems program. It tells each class when to go to which room. Without it, chaos!

Home example: Your home’s electrical wiring is a system. It delivers power to your TV, fridge, and lights safely.

Nigerian example: The traffic lights in Abuja are systems. They control when cars move and stop. If they fail, there is a big hold-up. Systems programming keeps such systems working.

Illustration:

  +-------------------+       +-------------------+
  |   HARDWARE        |       |   SYSTEMS         |
  | (CPU, memory,     |<----->|   PROGRAM         |
  |  disk, screen)    |       | (Operating System)|
  +-------------------+       +-------------------+
          ^                            ^
          |                            |
          |                            |
  +-------------------+       +-------------------+
  |   APPLICATIONS    |       |   RUST CODE       |
  | (Games, browsers) |       | (You write this!) |
  +-------------------+       +-------------------+
  

Mini summary: Systems programming builds the foundation that all other software uses. Rust is a language made for this job.

Lesson 2: Why Rust? The Superpowers of Rust

Definition: Rust is a programming language that focuses on speed, safety, and doing many things at once (concurrency).

Why it is important: Many programs crash because of memory errors. Rust stops those errors before the program even runs.

Simple explanation: Think of Rust as a strict but caring coach. It checks your code and says, “Wait, this part might cause a problem. Let’s fix it now.” Other languages might let you run and then crash later.

Real-life example: A bank uses Rust to handle millions of transactions. If the program crashes, people lose money. Rust prevents crashes.

School example: A teacher who marks your homework before you submit it is like Rust. A teacher who only marks after you fail is like some other languages.

Home example: Before you cook, your mum checks if the gas is off. Rust checks your code before it runs.

Nigerian example: In a busy market like Balogun in Lagos, a good trader counts money carefully before giving change. Rust counts and checks memory carefully to avoid “change” errors.

Illustration:

  Other languages:        Rust:
  Write code              Write code
       |                       |
       V                       V
  Run program             Compiler checks
       |                       |
       V                       V
  Maybe crash!            If safe, run
                          Else, fix first
  

Mini summary: Rust is safe, fast, and prevents many common bugs. That is why big companies love it.

Lesson 3: Installing Rust – Your Toolkit

Definition: Installing Rust means putting the Rust tools on your computer so you can write and run Rust programs.

Why it is important: You cannot build a house without tools. Rust has its own tools: rustc (the compiler) and cargo (the project manager).

Simple explanation: rustc turns your human-readable code into computer instructions. cargo helps you create projects, add libraries, and run tests.

Real-life example: A carpenter uses a hammer and saw. A Rust programmer uses rustc and cargo.

School example: Your school bag holds your books and pens. Cargo is like your school bag for Rust projects.

Home example: A toolbox in your house has a screwdriver and pliers. The Rust installation gives you a toolbox for coding.

Nigerian example: A tailor in Kano uses a sewing machine and scissors. A Rust programmer uses rustc and cargo to “stitch” code together.

Illustration:

  Your Computer
       |
       V
  Install Rust (from rustup.rs)
       |
       +--> rustc (compiler)
       |
       +--> cargo (project manager)
       |
       V
  Ready to write Rust!
  

Step-by-step installation:

  1. Go to rustup.rs in your browser.
  2. Follow the instructions for your operating system.
  3. Open a terminal or command prompt.
  4. Type rustc --version to check it works.
  5. Type cargo --version to check Cargo.

Mini summary: Install Rust using rustup. Then you get rustc and cargo to build programs.

Lesson 4: Your First Rust Program – Hello, World!

Definition: A “Hello, World!” program is the simplest program that prints a message to the screen.

Why it is important: It confirms that your tools work and you can run Rust code.

Simple explanation: You write a few lines. The computer reads them and shows “Hello, World!” on your screen.

Real-life example: When you say “Hello” to a friend, they say “Hello” back. Here, you tell the computer to say “Hello, World!”.

School example: The first day of school, you introduce yourself. This is your program’s introduction.

Home example: When you knock on a door, someone answers. This program knocks on the computer’s door.

Nigerian example: In Nigeria, we greet with “How are you?” The computer greets with “Hello, World!”.

Illustration:

  fn main() {
      println!("Hello, World!");
  }
  

Step-by-step:

  1. Open a terminal.
  2. Type cargo new hello_rust.
  3. Go into the folder: cd hello_rust.
  4. Open src/main.rs in a text editor.
  5. Replace the code with the example above.
  6. Save the file.
  7. Type cargo run.
  8. You will see Hello, World! on the screen.

Explanation:

  • fn main() { ... } – This is the starting point. Every Rust program begins here.
  • println!("Hello, World!"); – This prints the text inside the quotes.
  • The semicolon ; tells Rust that the instruction is finished.

Mini summary: “Hello, World!” is your first step. It shows you how to write and run a basic Rust program.

Lesson 5: Variables – Boxes for Keeping Things

Definition: A variable is a named box that stores a value. You can change what is inside (unless it is immutable).

Why it is important: Programs need to remember numbers, words, and other data. Variables hold that data.

Simple explanation: Imagine a kitchen cupboard. You put rice in one container, beans in another. You label them “rice” and “beans”. In Rust, you write let rice = 5;.

Real-life example: Your school bag has pockets for books, pens, and lunch. Each pocket is a variable.

School example: A register has columns for names, ages, and scores. Each column is like a variable.

Home example: Your phone’s contact list stores names and numbers. Each contact is a variable.

Nigerian example: A trader in Onitsha market has baskets for tomatoes, peppers, and onions. Each basket is a variable.

Illustration:

  let age = 13;
  let name = "Ada";
  let is_hungry = true;
  

Step-by-step:

  • Write let followed by the variable name.
  • Use = to assign a value.
  • End with a semicolon ;.
  • Use the variable name to read the value.

Mini summary: Variables store data. Use let to create them. You can change them later if you use mut.

Lesson 6: Data Types – Different Kinds of Boxes

Definition: A data type tells Rust what kind of value a variable holds: a number, a word, a true/false, etc.

Why it is important: Rust needs to know if you are adding numbers or joining words. Different types have different rules.

Simple explanation: You don’t put water in a paper bag. You use a bottle. Similarly, you use i32 for whole numbers, f64 for decimals, bool for true/false, and String for text.

Real-life example: A fuel gauge shows numbers. A name tag shows words. A light switch shows on/off (bool).

School example: Your report card has numbers for scores, letters for grades, and yes/no for attendance.

Home example: A TV remote has buttons for numbers (channels), on/off (bool), and volume (numbers).

Nigerian example: A market woman sells yams (counted in numbers), peppers (measured in cups), and “sold out” (true/false).

Table of common types:

TypeWhat it storesExample
i32Whole number (integer)42, -7, 0
f64Decimal number3.14, 2.5
boolTrue or falsetrue, false
StringText"Hello", "Lagos"
charSingle character'A', '7'

Illustration:

  let age: i32 = 13;
  let price: f64 = 500.50;
  let is_open: bool = true;
  let name: String = String::from("Ada");
  let grade: char = 'A';
  

Mini summary: Data types keep your data organised. Rust checks that you use the right type.

Lesson 7: Mutability – Change or Not to Change?

Definition: Mutability means you can change the value of a variable. In Rust, variables are immutable (cannot change) by default. You must add mut to make them mutable.

Why it is important: Immutability prevents accidental changes. It makes programs safer and easier to understand.

Simple explanation: Imagine a pencil writing on paper. You can erase and rewrite (mutable). But a pen writes permanently (immutable). Rust starts with pen by default; you choose pencil with mut.

Real-life example: Your birthday date never changes (immutable). Your age changes every year (mutable).

School example: Your name is fixed (immutable). Your class teacher can change (mutable).

Home example: The number of chairs in your house can change when guests come (mutable). The address of your house is fixed (immutable).

Nigerian example: The price of fuel can change (mutable). The location of your house is fixed (immutable).

Illustration:

  let x = 5;        // immutable, cannot change
  // x = 10;        // ERROR!
  let mut y = 5;    // mutable
  y = 10;           // OK!
  

Mini summary: Use let for unchangeable variables. Use let mut for changeable ones. Rust loves safety.

Lesson 8: Functions – Reusable Blocks of Code

Definition: A function is a named block of code that does a specific job. You can call it many times.

Why it is important: Functions avoid repeating code. They make programs shorter and easier to fix.

Simple explanation: Think of a function as a recipe. You write it once, then use it whenever you want to cook that dish.

Real-life example: A tailor has a pattern for a shirt. He uses the same pattern for many customers (function calls).

School example: The school bell rings at the same time every day. It is like a function called “ringBell()”.

Home example: Your blender has a “smoothie” button. You press it, and it does the same steps each time.

Nigerian example: A taxi driver has a route from Ikeja to Yaba. He repeats the same route (function) for many passengers.

Illustration:

  fn greet() {
      println!("Hello, friend!");
  }

  fn main() {
      greet();   // calls the function
      greet();   // calls it again
  }
  

Step-by-step:

  • Write fn followed by the function name.
  • Add parentheses ().
  • Open a block with { }.
  • Put the code inside.
  • Call the function by writing its name followed by ().

Mini summary: Functions are named blocks. Use fn to define them and () to call them.

Lesson 9: Comments – Notes for Humans

Definition: Comments are lines in your code that the computer ignores. They are for you and other humans to read.

Why it is important: Comments explain why you did something. They help you remember later and help others understand.

Simple explanation: Imagine writing notes in the margin of your school book. The teacher doesn’t mark them, but they help you study.

Real-life example: A recipe has notes like “bake for 20 minutes”. The oven ignores the note, but the cook reads it.

School example: Your class timetable might have small notes like “bring calculator”. They are comments for students.

Home example: A sticky note on the fridge says “buy milk”. It is a comment for the family.

Nigerian example: A signboard in traffic says “no parking”. It is a comment for drivers, not for the road.

Illustration:

  // This is a single-line comment
  let x = 5; // This comment explains the variable

  /*
     This is a multi-line comment.
     It can span many lines.
  */
  

Mini summary: Use // for short comments and /* ... */ for longer ones. They make code friendly.

Lesson 10: Printing and Input – Talking with the Computer

Definition: Printing means showing text on the screen. Input means the computer reads what you type.

Why it is important: Programs need to communicate with people. Printing shows results. Input lets users give data.

Simple explanation: Printing is like speaking. Input is like listening. A good program does both.

Real-life example: An ATM prints your balance. It also takes your PIN as input.

School example: A teacher asks a question (input) and writes the answer on the board (print).

Home example: A TV remote takes input (button press) and prints the channel on screen.

Nigerian example: A POS machine takes your card details (input) and prints a receipt (output).

Illustration:

  use std::io;

  fn main() {
      println!("What is your name?");
      let mut name = String::new();
      io::stdin().read_line(&mut name).expect("Failed");
      println!("Hello, {}!", name.trim());
  }
  

Step-by-step:

  • Use println! to print text.
  • Import std::io for input.
  • Create a String to hold input.
  • Use io::stdin().read_line() to read.
  • Use trim() to remove extra spaces.

Mini summary: Use println! to print. Use stdin().read_line to read input. Always trim extra spaces.

Lesson 11: The Rust Compiler – Your Strict Friend

Definition: The compiler is a program that turns your Rust code into a program the computer can run. It also checks for mistakes.

Why it is important: The compiler catches many errors before you run the program. This saves time and prevents crashes.

Simple explanation: The compiler is like a teacher who checks your homework before you submit it. If there is a mistake, the teacher tells you to fix it.

Real-life example: A building inspector checks a house before people move in. The Rust compiler checks your code before it runs.

School example: Before a debate, your teacher checks your speech for errors. That is the compiler.

Home example: Before cooking, your mum checks if all ingredients are available. That is the compiler.

Nigerian example: Before a bus leaves the park, the conductor checks that all passengers have paid. The compiler checks your code.

Illustration:

  Your code (hello.rs)
       |
       V
  rustc hello.rs   <-- compiler
       |
       V
  If no errors: hello executable
  If errors: messages to fix
  

Mini summary: The Rust compiler is strict but helpful. It catches mistakes early. Always fix compiler errors.

Lesson 12: Cargo – Your Project Manager

Definition: Cargo is Rust’s tool for creating projects, building code, running tests, and adding libraries.

Why it is important: Without Cargo, managing big projects is hard. Cargo makes everything organised.

Simple explanation: Cargo is like a project folder with extra powers. It creates a structure, downloads dependencies, and runs your program.

Real-life example: A wedding planner organises the venue, food, and music. Cargo organises your Rust project.

School example: A class monitor collects homework and keeps things in order. Cargo is the monitor for your code.

Home example: A toolbox keeps all tools in one place. Cargo is your coding toolbox.

Nigerian example: An event planner for a Nigerian wedding handles aso-ebi, food, and canopies. Cargo handles your project’s files and libraries.

Illustration:

  cargo new my_project
       |
       V
  my_project/
    ├── Cargo.toml
    └── src/
         └── main.rs
  

Common Cargo commands:

CommandWhat it does
cargo new nameCreates a new project
cargo buildBuilds the project
cargo runBuilds and runs the project
cargo checkChecks for errors without building
cargo testRuns tests

Mini summary: Use cargo new to start a project. Use cargo run to run it. Cargo keeps everything tidy.

Lesson 13: Common Mistakes for Beginners

Definition: Mistakes (bugs) are errors in code. Rust catches many before running.

Why it is important: Knowing common mistakes helps you avoid them.

Simple explanation: Rust is like a spell-checker. It underlines errors and suggests fixes.

Real-life example: Typing a wrong phone number. Rust checks if the number is valid.

School example: Forgetting to carry your pencil. Rust checks if you have all variables.

Home example: Forgetting to turn off the tap. Rust checks if memory is freed.

Nigerian example: Forgetting your change in a taxi. Rust checks that you don’t lose data.

Table of common mistakes:

MistakeWhat happensRust’s help
Using a variable without mutCannot change valueCompiler error
Forgetting semicolonUnexpected codeCompiler error
Wrong data typeType mismatchCompiler error
Reading input without trimExtra newlineYou must trim
Typo in variable nameCannot find valueCompiler error

Mini summary: Rust catches many mistakes early. Read compiler messages and fix them.

Lesson 14: Best Practices for Beginners

Definition: Best practices are good habits that make your code clean and safe.

Why it is important: Good habits make coding easier and more fun.

Simple explanation: Like brushing your teeth daily, coding habits keep your programs healthy.

Real-life example: Keeping your room tidy. Best practices keep code tidy.

School example: Writing neatly in your notebook. Best practices make code readable.

Home example: Washing plates after eating. Best practices prevent problems later.

Nigerian example: Keeping your market stall organised. Best practices keep code organised.

List of best practices:

  • Use meaningful variable names (e.g., score not s).
  • Write comments to explain why, not what.
  • Use cargo to manage projects.
  • Run your code often to catch errors early.
  • Read compiler errors carefully.
  • Keep functions small and focused.
  • Use consistent indentation.
  • Practice every day.

Mini summary: Good habits make you a better programmer. Start them now.

Lesson 15: Putting It All Together – Your First Complete Program

Let’s write a program that uses variables, functions, input, and printing.

Program: Greeting Card

  use std::io;

  fn greet(name: &str) {
      println!("Hello, {}! Welcome to Rust.", name);
  }

  fn main() {
      println!("What is your name?");
      let mut name = String::new();
      io::stdin().read_line(&mut name).expect("Failed to read");
      let name = name.trim();
      greet(name);
      println!("You are on your way to becoming a Rust Expert!");
  }
  

Explanation:

  • greet is a function that takes a name and prints a greeting.
  • main asks for input, reads it, trims it, and calls greet.
  • trim() removes the extra newline from input.
  • &str is a string slice, a borrowed string.

Mini summary: This program combines everything you learned in Module One. You can build it and run it!

Key Vocabulary

WordSimple Definition
Systems programmingWriting software that controls hardware and supports other programs.
RustA safe, fast programming language for systems.
CompilerA program that turns your code into a runnable program and checks for errors.
CargoRust’s tool for managing projects.
VariableA named box that stores a value.
Data typeThe kind of value a variable holds (number, text, true/false).
ImmutableCannot be changed.
MutableCan be changed.
FunctionA reusable block of code that does a job.
CommentA note in code that the computer ignores.
PrintShow text on the screen.
InputData typed by the user.
BugA mistake in code.
ConcurrencyDoing many things at the same time.

Important Concepts

  • Safety first: Rust prevents memory errors and data races.
  • Speed: Rust programs run as fast as C or C++.
  • Immutability by default: Variables cannot change unless you say mut.
  • Ownership and borrowing: (We will learn later, but it is Rust’s way of managing memory without a garbage collector.)
  • Cargo and crates: Cargo manages projects; crates are libraries you can use.
  • Compiler as teacher: The compiler catches many errors before running.

Step-by-step Explanations

How to write and run your first Rust program

  1. Install Rust from rustup.rs.
  2. Open a terminal or command prompt.
  3. Type cargo new hello_rust to create a project.
  4. Go into the folder: cd hello_rust.
  5. Open src/main.rs in a text editor.
  6. Replace the code with:
    fn main() {
        println!("Hello, World!");
    }
          
  7. Save the file.
  8. In the terminal, type cargo run.
  9. You will see Hello, World! on the screen.

Explanation: cargo new creates the project structure. cargo run compiles and runs your code. The main function is the starting point. println! prints text.

How to read input step by step

  1. Import std::io at the top.
  2. Create a mutable String: let mut name = String::new();.
  3. Call io::stdin().read_line(&mut name).
  4. Handle the result with .expect("Failed").
  5. Use name.trim() to remove extra spaces.
  6. Use the value with println!.

Real-life Examples

  • Banking: Rust is used in some banks to handle transactions safely.
  • Operating systems: Parts of Windows and Linux are being rewritten in Rust for safety.
  • Web browsers: Firefox uses Rust for its rendering engine.
  • Games: Some game engines use Rust for speed and safety.
  • Embedded devices: Rust runs on small chips in cars, robots, and IoT devices.

Nigerian Examples

  • POS machines: Many POS terminals in Nigeria need safe, fast software. Rust can power them.
  • Banking apps: Nigerian banks use secure systems. Rust helps prevent crashes and fraud.
  • Traffic lights in Lagos: Systems programming controls traffic lights. Rust can make them reliable.
  • Nollywood streaming: Video apps need to handle many users. Rust’s concurrency helps.
  • Agricultural sensors: Farmers use sensors to check soil. Rust can run on small devices.

Fun Examples Children Can Relate To

  • Video games: Rust makes games run smoothly without crashing.
  • Robots: Like Ada’s robot Chidi, Rust keeps robots from bumping into walls.
  • Chat apps: Sending messages without them getting lost.
  • Music players: Playing songs without skipping.
  • School quiz apps: Keeping score correctly.

Everyday Examples

  • Alarm clock: A program that checks the time and rings.
  • Microwave: A program that counts down and stops.
  • Traffic light: A program that changes lights on a timer.
  • ATM: A program that checks your PIN and gives cash.
  • Phone keyboard: A program that shows letters you tap.

Parent Tips

  • Encourage your child to ask questions. Curiosity is key in programming.
  • Install Rust together. It is free and safe.
  • Let them make mistakes. Errors are learning opportunities.
  • Praise effort, not just correct answers.
  • Use everyday examples (like traffic lights) to explain concepts.
  • Set a small daily coding time. Consistency helps.
  • Celebrate small wins, like printing “Hello, World!”.
  • Be patient. Learning to code takes time.
  • Ask them to teach you what they learned. Teaching is the best way to learn.
  • Keep it fun. Use games and stories.

Interesting Facts

  • Rust was voted the “most loved programming language” on Stack Overflow for many years.
  • Rust’s mascot is a crab named Ferris.
  • Rust is named after a fungus that is tough and resilient.
  • Rust has no garbage collector, yet it manages memory safely.
  • Rust can run on tiny computers and huge servers.
  • Many companies pay high salaries for Rust developers.
  • Rust is used in space satellites.
  • The Linux kernel now supports Rust.

Did You Know?

  • Did you know that Rust is used in space? Some satellites use Rust.
  • Did you know that the Linux kernel now supports Rust?
  • Did you know that Rust can help prevent hacking?
  • Did you know that cargo can run tests for your code automatically?
  • Did you know that Rust’s compiler gives very helpful error messages?
  • Did you know that Rust has a mascot called Ferris the crab?
  • Did you know that Rust is free and open-source?
  • Did you know that many big companies are rewriting software in Rust?

Remember This

  • Rust is safe, fast, and great for systems programming.
  • Variables store data. Use let to create them.
  • Use mut to make a variable changeable.
  • Functions are reusable blocks of code.
  • Comments help humans understand code.
  • The compiler checks your code before it runs.
  • Cargo manages your projects.
  • Practice every day to get better.
  • Rust prevents many common bugs.
  • You can become a Certified Rust Expert with practice.

Common Mistakes

  • Forgetting semicolons at the end of statements.
  • Trying to change an immutable variable without mut.
  • Using the wrong data type (e.g., putting text in a number variable).
  • Forgetting to call main() correctly.
  • Not trimming input when reading from the user.
  • Ignoring compiler error messages.
  • Using a variable before creating it.
  • Misspelling variable or function names.

Best Practices

  • Use meaningful names for variables and functions.
  • Write comments for tricky parts.
  • Keep functions short and focused.
  • Run cargo check often to catch errors.
  • Read the compiler messages carefully.
  • Format your code with cargo fmt.
  • Test your code with cargo test.
  • Practice every day.
  • Learn from mistakes.
  • Ask for help when stuck.

Illustrations and Diagrams

How Rust Works

  Your Code (main.rs)
        |
        V
  Rust Compiler (rustc)
        |
        +--> Errors? --> Fix and recompile
        |
        V
  Executable Program
        |
        V
  Runs on your computer
  

Rust Project Structure with Cargo

  my_project/
  ├── Cargo.toml    (project settings)
  └── src/
       └── main.rs  (your code)
  

Decision Flowchart: Should I use mut?

  Start
    |
    V
  Need to change the value later?
    |
    +-- Yes --> Use let mut x = ...
    |
    +-- No  --> Use let x = ...
    |
    V
  End
  

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

Rust vs Other Languages

FeatureRustPythonC++
SpeedVery fastSlowerVery fast
Memory safetyYes, compiler checksAutomatic, but slowerManual, error-prone
Learning curveModerateEasyHard
ConcurrencySafe and easyLimitedHard
Use caseSystems, embedded, webScripts, data scienceGames, systems

Immutable vs Mutable

PropertyImmutableMutable
Can change value?NoYes
Keywordletlet mut
SafetyHigherLower, but flexible
Examplelet x = 5;let mut y = 5; y = 10;

Data Types Overview

TypeCategoryExample
i32Integer42
f64Floating point3.14
boolBooleantrue
StringText"Hello"
charCharacter'A'

Lesson Summaries

Lesson 1: Systems programming controls hardware and supports apps. Rust is a great language for it.

Lesson 2: Rust is safe, fast, and concurrent. It prevents many crashes.

Lesson 3: Install Rust with rustup. You get rustc and cargo.

Lesson 4: “Hello, World!” prints a message. Every Rust program starts with fn main().

Lesson 5: Variables store data. Use let.

Lesson 6: Data types tell Rust what kind of value you have.

Lesson 7: Immutable by default. Use mut to change.

Lesson 8: Functions are reusable blocks of code.

Lesson 9: Comments are notes for humans.

Lesson 10: Printing shows text. Input reads what you type.

Lesson 11: The compiler checks your code and finds errors.

Lesson 12: Cargo manages projects and libraries.

Lesson 13: Common mistakes include missing semicolons and wrong types.

Lesson 14: Best practices make code clean and safe.

Lesson 15: Combine variables, functions, and input in a greeting program.

End-of-Module Summary

Congratulations! You have finished Module One of the Certified Rust Programming Expert course. You learned that systems programming is the foundation of all software. Rust is a modern language that is safe, fast, and perfect for systems. You installed Rust, wrote your first program, and learned about variables, data types, mutability, functions, comments, the compiler, Cargo, and input/output. You also saw many examples from Nigeria and everyday life. You now know common mistakes and best practices. Most importantly, you are ready to write simple Rust programs and understand how they work. Keep practising, and you will become a Certified Rust Programming Expert!

Frequently Asked Questions

  1. What is Rust? Rust is a programming language for building fast and safe software.
  2. Is Rust hard to learn? It is a bit stricter than some languages, but very beginner-friendly with practice.
  3. Do I need to know another language first? No. You can start with Rust.
  4. What is Cargo? Cargo is Rust’s tool for managing projects.
  5. Why do I need to use mut? To allow a variable to change. Rust defaults to safety.
  6. What is a compiler error? A message from Rust saying your code has a problem.
  7. Can Rust run on my phone? Yes, Rust can run on many devices.
  8. Is Rust free? Yes, completely free and open-source.
  9. What can I build with Rust? Games, operating systems, web servers, robots, and more.
  10. How do I get help? Read the compiler messages, ask a teacher, or search online.

Matching Exercises

Match the word to its definition.

WordDefinition
1. VariableA. A reusable block of code.
2. FunctionB. A named box that stores a value.
3. CompilerC. A note in code that the computer ignores.
4. CommentD. Turns code into a runnable program.
5. CargoE. Rust’s project manager.

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

Scenario-based Exercises

  1. Scenario: You want to store your age in a program. Which data type should you use?
    Answer: i32 (whole number).
  2. Scenario: You need a variable that will change when you score a goal. Should it be mutable?
    Answer: Yes, use let mut score = 0;.
  3. Scenario: Your program asks for your name and prints it. What function do you use to read input?
    Answer: std::io::stdin().read_line().
  4. Scenario: You write let x = 5; x = 10; and get an error. Why?
    Answer: x is immutable. Use let mut x = 5;.
  5. Scenario: You want to reuse a block of code that greets users. What should you create?
    Answer: A function.

Group Activity

Title: “Build a Greeting Robot”

Instructions: In groups of 3–4, write a Rust program that asks for each person’s name and then prints a greeting for each. Use a function for the greeting. One person types, one person reads the compiler errors, one person explains the code. Share your program with the class.

Goal: Practice variables, input, functions, and printing.

Individual Activity

Task: Write a Rust program that stores your name, age, and favourite food in variables. Then print them in a sentence like: “My name is Ada, I am 13 years old, and I love jollof rice.”

Hint: Use let and println!.

Mini Project

Project: “My Daily Routine”

Write a Rust program that prints your daily routine. Use at least three functions: one for morning, one for afternoon, and one for evening. Call them in main(). Add comments to explain each part.

Example output:

  Morning: Wake up, brush teeth, eat breakfast.
  Afternoon: Go to school, study, play.
  Evening: Do homework, eat dinner, sleep.
  

Practical Assignment

Assignment: Create a new Cargo project called about_me. In main.rs, write a program that:

  1. Prints “What is your name?”
  2. Reads the user’s name.
  3. Prints “How old are you?”
  4. Reads the age.
  5. Prints a sentence: “Hello [name], you are [age] years old!”
  6. Uses a function to print the final greeting.

Submit: Your main.rs file and a screenshot of the program running.

Key Takeaways

  • Rust is a safe, fast language for systems programming.
  • Install Rust with rustup and use cargo for projects.
  • Variables store data. Use let and mut.
  • Data types: i32, f64, bool, String, char.
  • Functions are reusable blocks.
  • Comments explain code to humans.
  • The compiler catches errors before running.
  • Print with println!, read input with stdin().read_line().
  • Practice and read error messages carefully.
  • You are on your way to becoming a Certified Rust Expert.

Classroom Discussion Questions

  1. Why is safety important in systems programming?
  2. How is Rust’s compiler like a teacher?
  3. What would happen if traffic lights had bugs?
  4. Why does Rust make variables immutable by default?
  5. How can functions make code shorter?
  6. What is the difference between a variable and a constant?
  7. How does Cargo help in big projects?
  8. Why do we write comments?
  9. What did Ada learn from the robot story?
  10. Where do you see systems programming in Nigeria?

Preparation for Module Two

In Module Two, we will dive deeper into Rust. We will learn about:

  • Control flow: if, else, and match.
  • Loops: loop, while, and for.
  • Expressions and statements.
  • Ownership and borrowing (Rust’s superpower!).
  • Writing bigger programs.
  • Debugging and testing.

To prepare, make sure you have completed the practical assignment and can run simple Rust programs. Review your notes on variables and functions. Bring your curiosity!

See you in Module Two!


End of Module One – 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.
→