> As we see below, you may still need to write some code to convert from C types to something that is more ergonomic to use in Rust. But the marshaling ABI-wise is minimal.
Exactly, as much as I love writing Rust code, there is nothing that is more frustrating that maintaining bindings from C to Rust. Then you'd have to create another idiomatic binding on top of it. Sure bindgen is great, but Zig's cImport and Swift's ClangImporter take this further.
They both use clang modules to tackle the first part. A autogenerated idiomatic solution would be great for Rust, but sadly it doesn't exist.
Re:How to rewrite it in Rust
by paulddraper on Monday December 02, 2019 @11:46PM
(#21690007)
At some point, I figure you will always need human intervention to get actually idiomatic interop, whether it's C marshalling, JSON serialization, database persistence, etc.
As we see below, you may still need to write some code to convert from C types to something that is more ergonomic to use in Rust. But the marshaling ABI-wise is minimal.
> Turns out the original tinyvm will crash for some reason when you have multiple layers of includes
It's actually crashing because there are no lines of code in the file, so certain data structures never get initialized.