Looking for a C++ for Rust Dev Guide

I'm writing Rust bindings / a thin C++ wrapper for a larger C++ project. I need to learn just enough C++ to be dangerous. Does anyone have a good guide for C++ for Rust Devs?

I'd say it works the other way for C++ - you need to know only tiny amounts to be dangerous, and a lot to be safe.
It's nice to know that there are people who have learnt Rust before C++.


I'm not sure it's what you're looking for, and it definitely doesn't have Rust programmers in mind, but I've used A Tour of C++ by Bjarne Stroustrup in the past and found it a concise and useful read.


extern "C" is your friend.

Decide early how to handle errors.

Whenever possible, choose concrete types (e.g. yes to uint64_t / u64; no to unsigned).

Caller-allocates works well across ABI boundaries. If the Rust code returns anything allocated on the heap make certain you understand who is responsible for freeing that thing, where it was placed, and how to prevent Rust from automatically freeing it.


I think this isn't just true, but something that should be broadcast hourly from Elon Musk's constellation of satellites. grin

If you intend to write C++, may I suggest (gently, then strongly, then with an incessant bleating) that you should read the Google C++ Style Guide ( Google C++ Style Guide ) and try to practice it in all ways ?

I've found it really pays to follow those rules, even when you think they're wrong.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.