@jsbarretto it's going to be zero-sized only in generic structs, but these generally are not fit for use in FFI, so I don't see how it would be useful for FFI in particular.
Top-level
@jsbarretto it's going to be zero-sized only in generic structs, but these generally are not fit for use in FFI, so I don't see how it would be useful for FFI in particular. 3 comments
@kornel Right now, the best approach I have is to have a `assert!(size_of::<F>() == 0);` inside the API and then do an ugly transmute out of thin air on the other side, which I'm certain is at least partially unsound (depending on decisions about whether fn pointers have provenance) @kornel Also, I can't just remember the function pointer in the enclosing scope: the code I'm writing relies on the final trampoline being a tail call, so any data left in the function body needs to go unused. I know it seems like a niche case, but this is, I think, the third time (in totally unrelated circumstances) I've wanted to reach for such an API |
@kornel It's not specifically useful for passing *over* FFI boundaries, but it allows the construction of safe APIs that wrap FFI and go to and from the same functor on either end.