Rust Programming with RustRover

Write fast, memory-safe Rust in RustRover: ownership and borrowing, enums and pattern matching, traits and generics, iterators, tests and a command-line tool.

Intermediate · Software Development · about 14 hours · 5 modules · certificate on completion

Taught by Wei-Chéng Liú, Jae-Wòn Parkk, AI Learning Companions.

About this course

Rust gives you the speed and control of a systems language with guarantees no other mainstream language offers: no null pointers, no use-after-free, no data races, all checked before the program runs. The price is learning to think like its compiler, and this course teaches exactly that, in RustRover, JetBrains' IDE for Rust. Every lesson teaches part of the language and shows it in RustRover step by step, with the keyboard shortcuts for macOS, Windows and Linux: running Cargo, reading and fixing compiler errors with quick-fixes, navigating the standard library, refactoring, debugging and the test runner.

You start with ownership, borrowing and lifetimes, deliberately breaking the rules to read the errors the compiler gives. Then you model data with structs, enums and pattern matching, handle failure with Option, Result and the ? operator, share behaviour with traits and generics, and process data with collections, closures and iterators. The last module organises a package into a library, a binary and modules, tests it with unit, integration and doc tests, and builds a command-line tool. Each module ends with a lab, from fixing a program the borrow checker rejects to building and testing csvsum, and the capstone is logstat, a log analyser that must match a given report exactly.

What you'll learn

  • Explain Rust's ownership, borrowing and lifetime rules, and fix the compiler errors that enforce them
  • Model data with structs and enums, and handle every case with pattern matching
  • Handle missing values and failures with Option, Result, the ? operator and custom error types
  • Write reusable code with traits, generics and trait objects
  • Process data with collections, closures and iterator chains
  • Organise a Cargo package into modules, test it with unit, integration and doc tests, and ship a command-line tool

Skills you'll gain

Rust, RustRover, Ownership and borrowing, Lifetimes, Pattern matching, Error handling with Result, Traits and generics, Iterators and closures, Cargo, Unit and integration testing

Tools

RustRover, Rust, Cargo, rustfmt, Clippy

Before you start

Confident programming in another language (functions, loops, structs or classes, and collections), as in Python Programming with PyCharm, Java Programming with IntelliJ IDEA or Go Programming with GoLand. You need Rust installed with rustup (rustup.rs), which brings cargo, rustfmt and Clippy (on Windows it also needs the Visual Studio C++ build tools), and RustRover, which is free for non-commercial use such as learning.

Modules

  1. Ownership, borrowing and lifetimes

    Set up Rust and RustRover, then learn the rules that make Rust memory-safe without a garbage collector: ownership and moves, borrowing with shared and mutable references, and lifetimes, with the compiler errors that enforce each one.

    • Cargo, RustRover and your first program (12 min)
    • Ownership and moves (14 min)
    • Borrowing and references (14 min)
    • Lifetimes (13 min)
    • Hands-on lab: Fix the borrow checker's complaints
  2. Structs, enums and pattern matching

    Model data with structs and their methods, with enums whose variants carry data, and with exhaustive pattern matching; then handle missing values and failures with Option, Result and the ? operator.

    • Structs and methods (13 min)
    • Enums and pattern matching (14 min)
    • Option and Result (14 min)
    • Hands-on lab: Drive a robot with enums and match
  3. Traits and generics

    Share behaviour between types with traits, choose between static and dynamic dispatch, and write generic code with trait bounds, using the standard traits that make your types feel built in.

    • Traits (14 min)
    • Generics and standard traits (14 min)
    • Hands-on lab: Shapes and a generic top-N
  4. Collections, closures and iterators

    Work with Rust's collections (vectors, UTF-8 strings and hash maps), capture behaviour in closures, and process data with lazy iterator chains that compile to fast loops.

    • Vectors, strings and hash maps (13 min)
    • Closures (13 min)
    • Iterators (14 min)
    • Hands-on lab: Word frequencies with iterators and closures
  5. Modules, testing and a command-line tool

    Organise a Cargo package into a library, a binary and modules; test it with unit, integration and doc tests; and build a command-line tool that reads files, reports errors properly and ships as an optimised binary.

    • Modules, crates and Cargo (13 min)
    • Testing (14 min)
    • A command-line tool (14 min)
    • Hands-on lab: Build and test csvsum, a command-line tool

Project: Build logstat, a log analyser

Build logstat, a command-line tool that reads a service's log file and prints a summary: how many lines were well formed, which were malformed (by line number), how many lines there were at each level, which modules logged the most errors, latency statistics, and the time range covered. SPEC.md gives the exact line format, report format and exit codes, and expected-report.txt shows what a correct tool prints for the provided app.log, with and without --module payments. Structure it as a Cargo package with a library (parsing, aggregation and the report) and a thin binary. Model the log level as an enum that implements FromStr and Display, parse each line into a struct (borrowing from the line with a lifetime parameter, or owning its fields: your choice, explained), return a custom error enum for malformed lines, aggregate with iterators, closures and a HashMap, and give the report a Display implementation. Report problems on standard error with the right exit code. Test it with unit tests for parsing, integration tests that run the report on small samples, and at least one doc test, and keep it clean under cargo clippy and cargo fmt.

Part of

RustRover is a trademark of JetBrains s.r.o. This course is independent: JetBrains hasn't made or endorsed it.

Start the course free