Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes I realized porting a template library to Rust would basically require implementing a whole new compiler (easily more difficult to implement than all of Rust). Like you said, the only workable way is to link to C++ source code (fully translated units/obj files) compiled by clang. Rust would have to learn how to use C++'s name mangling, data alignment, and calling conventions to be able to invoke C++ functions. See my other post in this thread.

Basically it would be a "extern C++". The FFI to C++ would hopefully have as low overhead as "extern C" while making it easier for C++ codebases to gradually adopt Rust.



> Rust would have to learn how to use C++'s name mangling, data alignment, and calling conventions to be able to invoke C++ functions.

This is already supported (via Bindgen).


Thanks for pointing me to this. Wow. Looks like I can finish learning Rust.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: