Rust in a C++ project


Hello, I’m new to Rust and I just want to know if it is possible to add Rust code to an existing C++ project. It’s a game called Minetest (similar to Minecraft), which is written in C++ and I want to write a new mapgen, but in Rust.

The Boilerplate Code looks something like this

I just want to know if it is possible an where I can start to learn



Rust can expose a C ABI, similar to how you’d do it in C++, so you can do that, and then the C++ will think Rust is C.

I don’t know anything about minetest, so that’s all the advice I have to offer.


Here’s a very simple example project showing how to build a Rust library with a C API and call it from C++: