Easy refactoring to Rust-Lang

Many projects are being rewritten in Rust-Lang and some of them prefer refactoring. I took a look at the technique of refactoring and calling Rust-Lang codes through the C programming language, but it's a bit complicated and difficult, or at least difficult for a newbie like me. I wanted to know if there is a special tool or technique for this task or not?

Thank you.

Rust FFI is efficient, and decently ergonomic, but still quite complex. The way most RIIR projects handle it is by rewriting small library portions of their codebases in Rust, one at a time, so that they don't have to throw out the whole thing and start over.

I think the best example of a successful workflow for RIIR I can think of is how fish-shell is approaching it. They even have a document explaining their overall strategy and a developer guide describing the smaller details of how it works.

In general, most RIIR projects use a mix of autocxx, cxx, and bindgen. c2rust is a transpiler for converting C into Rust, but it's highly non-idiomatic and I doubt that using it on a project would get you much closer to a finished port.


It depends on your project and your API interactions. For some projects it makes sense to create interfaces that bridge the communication during a step-by-step refactoring; while for some other projects it makes more sense to just rewrite everything from scratch.

1 Like