Interoperating Between Objective-C and Rust
sasheldon.com
sasheldon.com
What makes interoperability possible is Rust's existing C interop.
Rust doesn't have any Swift interop.
Like the languages themselves the bridges are polar opposites, of course – static and safe vs. flexible and interactive, etc. It's great to see it (and learn from it) being done on the other side of those tradeoffs.
Do you know if casting to a function also make objc_msgSend_stret and objc_msgSend_fpret unnecessary? I haven't yet worked with any methods that return structs or floating point values, so I haven't had to deal with them yet.
Edit: Oh, nope, my bad, objc_msgSend_stret is the one where you definitely have to cast: http://blog.lazerwalker.com/blog/2013/10/12/the-objective-c-...
objc_msgSend()'s type is not expressible in C; the only time it is correct to call objc_msgSend without a cast is when calling a method IMP with the literal vararg type of id (*method) (id self, SEL sel, ...);
In other words, essentially never.
It's a lot easier to work with the Foundation Objective-C API. They both manipulate the same data structures (or nearly the same with zero-cost bridging) but Foundation is far less verbose and a little more dynamic (no need for manual buffer allocations and configuring callback structures).
Otherwise having platform FFI pain, C and C++ interop pain is just too much.