Does Rust offer C interop?

Yes.

The Rust compiler can only do safety checking on Rust source code. It has no idea what goes on inside any C code you link into the system (Neither does the C compiler for that matter, it checks nothing much). Ergo any such linkage must be "unsafe".

Think of it like this: When Rust passes control to C it's like you jumping into a pit full of vipers in the hope that none of them bites you. I might put up a sign "unsafe, vipers in pit".

13 Likes