Re:A Guide to Porting C/C++ to Rust
by bluejekyll on Sunday January 29, 2017 @03:04PM
(#13516253)
The interface is FFI, it has to be unsafe, because you can't guarantee anything about the C code.
The rust code though, can be converted to pure Rust. A strategy I use and most other FFI code I've seen, is to have a shim layer, which is unsafe, that calls through to safe code. And vise versa for calling out to C. The function definitions don't need to be unsafe, just the direct calls to C and conversions to C types.
Re:A Guide to Porting C/C++ to Rust
by Manishearth on Sunday January 29, 2017 @05:09PM
(#13517046)
> This isn't a syntax problem. It's a semantic problem.
I never said it was.
You can still make trivial semantic transformations on code by hand or by using a tool (corrode could do it itself, too) and make it safe. As bluejekyll said it's a bit tricky since you can't guarantee anything about the calls until you port those too.
This isn't a syntax problem. It's a semantic problem.