3 ms·
Rust's data model diverged from C++, but it's not very far from C. It's easy enough to write C-compatible structs and functions in Rust, as long as you don't ne
by simonask 3y ago
Rust's data model diverged from C++, but it's not very far from C. It's easy enough to write C-compatible structs and functions in Rust, as long as you don't need `Drop`. Even tagged unions (data carrying enums) are supported to some degree.
- Animats 3y agoIt's the lack of backlinks to parents that gets you. Rust can do hierarchies where an A owns a B which owns a C, but if you have a reference to C, you can't get back to A. (Yes, weak pointers, reference counts, unsafe hacks, etc. can work around that. But the language really doesn't like links to parents.) So there's no direct translation from a C++ object hierarchy to Rust structs.