-
Notifications
You must be signed in to change notification settings - Fork 0
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
async function traits #14
Comments
I suppose that is to work around the lack of variadic generic parameters support in rust. |
The compiler will need to know about them to get type inference with HRTBs to work. Today, this doesn’t compile: fn example<F: for<'a> AsyncFn1<&'a u32, Output = ()>>(func: F) {}
example(|x| async { dbg!(x); }); and that’s because the |
Does this get easier if we stabilize |
I mean, potentially. If fn example<F>(func: F)
where
F: for<'a> Fn(&'a u32) -> _,
for<'a> <F as Fn(&'a u32) -> _>::Output: Future<Output = ()>,
{} Or maybe, the compiler could have the example Just Work by propagating the |
See async_fn_traits. Essentially traits for functions which return a future. I'm not clear on why there are versions for different numbers of arguments rather than having a generic parameter for the arguments (like the
Fn
traits). I'm also not clear on how much these traits are just a convenience vs how much the compiler will need to know about their correspondence with theFn
traits to be useful.The text was updated successfully, but these errors were encountered: