You've got a C codebase you'd like to move to Rust, but you're not sure where to
start?
This course is for you!
You'll learn techniques for migrating C codebases to Rust by solving exercises.
You'll learn how to maintain a safe mixed C-Rust codebase, incrementally migrate
modules, translate common C idioms to Rust, and use the debugging tools you'll
need when things inevitably break — one exercise at a time.
Note
This course has been written by
Mainmatter.
It's one of the trainings in
our portfolio of Rust workshops.
Check out our landing page if
you're looking for Rust consulting or training!
Clone this repository to your local machine:
git clone https://github.com/mainmatter/migrating-c-to-rustWe recommend you work on a branch, so you can easily track your progress and pull in updates from the main repository, if needed:
cd c-to-rust-migration-book
git checkout -b my-solutionsAll exercises are located in the exercises folder. Each exercise is structured
as a Rust package. The package contains the exercise itself, instructions on
what to do (in src/lib.rs), and a test suite to automatically verify your
solution.
To verify your solutions, we've provided a tool to guide you through the course:
the wr CLI, short for "workshop runner". Install wr by following the
instructions on
its website.
Once you have wr installed, open a new terminal, navigate to the top-level
folder of the repository, and run:
wrwr will verify the solution to the current exercise. Don't move on to the next
section until you've solved the exercise for the current one.
- Rust (follow instructions
here).
Ifrustupis already installed on your system, runrustup update(or another appropriate command depending on how you installed Rust on your system) to make sure you're running on the latest stable version. - A C compiler. The one provided by your operating system will be good enough.
- (Optional but recommended) An IDE with Rust autocompletion support. We
recommend one of the following:
- RustRover;
- Visual Studio Code with the
rust-analyzerextension.
Copyright © 2024- Mainmatter GmbH (https://mainmatter.com), released under the Creative Commons Attribution-NonCommercial 4.0 International license.