-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fn-types #73
Comments
So you're basically implementing closures manually so that they're FFI-safe? I think the only way to do this would be with a proc macro, right? Specially because we'd need variadic params in Fn's generics. But it might be a bit complicated, you'd have to know what variables are captured and etc. We could also use a hack like for tuples. |
Because "extern C fn" can be instrumented with generics within the I don't know if we have to implement variadic functions. For multiple parameters we could implement: impl<T, TParam1, TParam2, TResult> From<T> for RBoxFnOnce<Tuple2<TParam1, TParam2>, TResult> where T: FnOnce(TParam1, TParam2) -> TResult; |
@mineichen FWIW I did this as well, and though it's a bit cumbersome I had the same approach for multiple parameters (using tuples) and couldn't think of anything much better. |
I'm currently missing a stable_abi alternative for Fn, FnMut and FnOnce. I'm planning to implement those in the following style:
Usage looks like:
I'm not very experienced, but IMO this shouldn't have undefined behavior. If you are interested to integrate such functionality into stable_abi, I'm happy to fork your repo and push everything upstream eventually. Otherwise, I'll just create my own repo. Please let me know about your preferences.
The text was updated successfully, but these errors were encountered: