Comment by pornel

Comment by pornel 8 days ago

0 replies

Fun fact: Box<T> is allowed in C FFI in arguments and return types. From C's perspective it's a non-NULL pointer to T, but on the Rust side it gets memory management like a native Rust type.

Option<Box<T>> is allowed too, and it's a nullable pointer. Similarly &mut T is supported.

Using C-compatible Rust types in FFI function declarations can remove a lot of boilerplate. Unfortunately, Vec and slices aren't one of them.