A transpiler that migrates C99-compliant code to unsafe Rust, preserving functionality and enabling incremental refactoring.
C2Rust is a transpiler that converts C99-compliant code into unsafe Rust, enabling the migration of legacy C projects to the Rust ecosystem. It focuses on preserving the original functionality so that existing test suites continue to pass after translation. The project also includes refactoring tools to help developers incrementally improve the safety and idiomatic quality of the generated Rust code.
Developers and teams maintaining legacy C codebases who want to migrate to Rust for memory safety and modern tooling, particularly those working on systems software, libraries, or embedded projects.
C2Rust provides a pragmatic, incremental path to Rust adoption by automating the initial translation of C code, which can then be refined. Its integration with standard build systems and focus on correctness makes it a practical choice for real-world migration projects.
Migrate C code to Rust
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
C2Rust ensures translated Rust code passes existing C test suites, maintaining correctness during migration as stated in the README's primary goal.
It works seamlessly with CMake, Meson, Bear, and other tools to generate compilation databases, easing integration into existing C workflows.
The c2rust-refactor tool assists in automating the transition from unsafe to safer Rust, though it's admitted to be in early development.
Allows verification of translated code against the original C implementation, adding a layer of correctness assurance for critical projects.
The refactoring tools are 'still in the early stages' per the README, requiring significant manual effort to achieve safe, idiomatic Rust.
Installation requires specific LLVM versions, clang, and system dependencies like openssl, which can be cumbersome and error-prone across platforms.
The official manual hasn't been updated since 2019, forcing users to rely on in-tree docs that may be incomplete, as noted in the README.
C2Rust only supports Linux and macOS, excluding Windows and other systems, which restricts its use for cross-platform migrations.