Automatically transpile an existing C codebase into Rust to begin a migration to memory-safe code.
Run your original C test suite against the transpiled Rust output to verify the behavior is identical.
Gradually refactor unsafe Rust output from the transpiler into safe idiomatic Rust using the included refactoring tool.
Requires a full C compiler toolchain plus LLVM system libraries in addition to the Rust toolchain.
C2Rust is a tool for developers who want to take existing C code and convert it into Rust code automatically. Rust is a programming language designed to prevent common memory-related bugs and security vulnerabilities that are frequent in C programs. The conversion process is called transpilation, and C2Rust handles the mechanical parts of that translation so you do not have to rewrite everything from scratch. The tool reads your C source files and produces Rust code that does the same things your C code did. The resulting Rust code is not written in a clean or idiomatic Rust style, it uses an internal mode called unsafe Rust that closely mirrors the original C structure. The main goal is that your test suite should still pass after the conversion, meaning the behavior is preserved even if the code style is rough. Because the output is unsafe Rust rather than fully safe Rust, there is still manual work to do after the automatic step. The project includes a separate refactoring tool meant to help with that process, letting you gradually clean up the translated code and shift more of it into Rust's safe subset. The README notes this refactoring work is still in early stages. There is also a cross-checking feature that lets you run both the original C program and the translated Rust program at the same time against the same inputs, comparing their outputs to verify the translation did not introduce any differences. This is useful for catching subtle behavioral mismatches before you retire the C version. Installing C2Rust requires a C compiler toolchain and the LLVM system libraries in addition to the Rust toolchain itself. Setup instructions are provided for Ubuntu, Arch Linux, macOS, and NixOS. The transpiler can be installed from the standard Rust package registry or directly from the project's source code repository.
← immunant on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.