Galois, Inc. Logo + Immunant, Inc. Logo

C2Rust Demonstration

C source code
void insertion_sort(int const n, int * const p) { for (int i = 1; i < n; i++) { int const tmp = p[i]; int j = i; while (j > 0 && p[j-1] > tmp) { p[j] = p[j-1]; j--; } p[j] = tmp; } }
or
Generated Rust source code

The C2Rust project is being developed by Galois and Immunant. This tool is able to translate most C modules into semantically equivalent Rust code. These modules are intended to be compiled in isolation in order to produce compatible object files. We are developing several tools that help transform the initial Rust sources into idiomatic Rust.

The translator focuses on supporting the C99 standard. C source code is parsed and typechecked using clang before being translated by our tool.

This project is available under the BSD-3 license.

Environment

Host environment
The translator is running on Ubuntu 22.04.5 LTS with x86_64 architecture. With this approach to translation details of the host system's libraries can be embedded in the translation. The generated C code might not link correctly on other platforms.
Rust environment
The generated code is currently targeting:
nightly-2019-06-22

Contact

To report issues with the transpiler or demo, please use our Issue Tracker.

For more information, email us at c2rust@galois.com.