Rust Programming

Objectives

  • To be able to write programs in Rust.
  • To master the rich set of Rust libraries (crates).

Audience

  • This is a beginner level course suitable for anyone wanting to use Rust for developing libraries (crates) or applications.

Course Format

  • Duration of the course is 42 academic hours.

Prerequisites

  • Experienced programmers with good programming background in a language such as C, C++, Java, Go, Perl, Python, PHP, or Ruby

Syllabus

Rust

  • Installing Rust
  • Why use Rust?
  • Configuring IDE or editor
  • Cargo - the package and dependency manager of Rust
  • Hello World
  • Primitives - basic (scalar) types in Rust
  • Inferred types
  • Numbers, characters, strings
  • String slices
  • Variables, mutability
  • Scope of variables
  • Control flow (if, for, loop)
  • They type system of Rust
  • Error handling
  • Special types: Option, Result
  • Pattern matching (match, Ok, Err, Some, None)
  • Compound types (Vectors, Hashes, Structs, Tuples, etc.)
  • Vectors
  • Structs
  • Enums
  • Functions
  • Creating libraries in Rust
  • Generics and Traits
  • Collections
  • Variable lifetime
  • Smart pointers
  • Dependency management
  • Backward compatibility
  • Distributing executables for multiple platforms (CI/CD, cross compilation)

Regular Expressions in Rust

  • The regex flavor of Rust
  • Matching strings
  • Capturing the match
  • Matching repetitions
  • Replacing strings
  • Compiling regular expressions only once

Reusable Rust library

  • Use a Rust crate from Python
  • Use a Rust crate from C

Relevant Computer Science topics

  • Data embedded in the source code
  • What is the Stack, Heap
  • Pointers
  • Memory management, memory safety
  • Manual memory management with allocation and freeing
  • Reference counting
  • Garbage collection
  • Compiled vs. Interpreted languages
  • Statically type vs. dynamically typed languages
  • Loosely typed vs strongly typed

Understanding memory safety, ownership and borrowing

  • What is Ownership?
  • How do we pass ownership
  • References and Borrowing when passing parameters to functions
  • The Slice type
  • Lifetimes

Functional programming in Rust

  • Iterators
  • Closures
  • Function pointers

Crates

  • Module system
  • Creating an executable (binary) crate
  • Creating a library crate
  • Packaging crates
  • Distributing crates
  • One crate per repo
  • Multiple crates per repo (monorepo)

Fearless Concurrency with threading

  • Run code simultaneously
  • Passing data back-and-force between threads
  • Sharing data between threads
  • Avoiding dead-locks and other nastiness

CLI - Command line applications in Rust

  • Using ARGS for simple programs
  • Introduction to Clap, the Command Line Argument Parser of Rust
  • Positional arguments
  • Named arguments
  • Required vs optional arguments
  • Exclusive arguments
  • Providing help

Handling well-known file formats

  • JSON
  • YAML
  • TOML
  • INI
  • CSV

Testing your code

  • Writing unit tests
  • Writing integration tests
  • Controlling how test are run

Optional topics

  • Building API in Rust
  • The liquid Templating system
  • Concurrency with async programming
  • Macros - A few simple examples with declarative macros

Let's talk

If you would like to bring this course to your organization, let's talk about it! You can reach me via email at [email protected] or you can go ahead and schedule a chat:

Contact me