Rust in a C++ project


#1

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

http://dev.minetest.net/Mapgen#Boilerplate_Mapgen_Code

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

Regards
Markus


#2

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.


#3

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