Sections
IntroductionGetting StartedWhat is Rust?InstallationYour First ProjectIDE SetupRust Language FundamentalsVariables and TypesFunctions and Control FlowOwnershipBorrowing and SlicesStructs and EnumsError HandlingCollectionsClosures and IteratorsTraits and GenericsModules and CratesProject Setup and ToolingCargo In DepthDependenciesTestingDaily WorkflowPyO3 and LogferryPyO3 OverviewExposing FunctionsExposing ClassesError Handling in PyO3Multithreading and the GILlogferry WalkthroughDistributionCargo CheatsheetReferencePython → Rust CheatsheetTroubleshooting
Rust Language Fundamentals
2 min read
This chapter teaches the Rust language by mapping every concept to its Python equivalent. Each article shows the Python way first, then the idiomatic Rust way, then explains what changed and why.
Examples lean on MLOps scenarios — log parsing, config loading, data pipelines — so the context stays familiar.
Articles
| Article | Topics covered |
|---|---|
| Variables and Types | let, mut, shadowing, primitives, String vs &str, formatting |
| Functions and Control Flow | fn, implicit return, if/else, loop, while, for, ranges |
| Ownership | The three ownership rules, move semantics, Copy, clone() |
| Borrowing and Slices | &T, &mut T, the borrow rules, slices |
| Structs and Enums | struct, impl, methods, enums with data, match |
| Error Handling | Option<T>, Result<T,E>, the ? operator |
| Collections | Vec, HashMap, HashSet |
| Closures and Iterators | Closures, move, lazy iterators, adapters |
| Traits and Generics | trait, impl Trait, Box<dyn Trait>, Send + Sync, generics, lifetimes |
| Modules and Crates | mod, pub, use, external crates, Cargo.toml |
Prerequisites
Chapters 1 — Getting Started should be complete. You should have Rust installed and be able to run cargo new and cargo build.
Next
After completing this chapter, move on to Chapter 3 — Project Setup and Tooling or jump straight to Chapter 4 — PyO3 and logferry if you are eager to see how Rust talks to Python.