Huh TIL you can use fn as a type. Thanks! :D It worked now I won't have a vtable lookup :D
-
-
Replying to @mgattozzi @sgrif
Oh no it turns out async fn is impl Future and now I can't do anything because you can't have that inside a trait
2 replies 0 retweets 4 likes -
Replying to @mgattozzi @sgrif
ok, yea that's a different story. I think you even won't be able to `Box` them, because every one of those functions can have a different return type (different future), so even if the `async fn` declaration looks like they all have the same return type, they don't
2 replies 0 retweets 0 likes -
Replying to @oli_obk @mgattozzi
When I say "box everything", I'm including the future itself. e.g. `Box::new(|args| async_fn(args).map(|f| f.boxed()))`
1 reply 0 retweets 0 likes -
Which would let you have `Vec<Box<dyn Fn(Args) -> Pin<Box<dyn Future<Output = Whatever>>>>>`
2 replies 0 retweets 0 likes -
Replying to @sgrif @mgattozzi
yea, but at that point you don't need to box the function anymore. You can just get a `fn(Args) -> Pin<Box<dyn Future<Output = Whatever>>>` for each element in the `Vec`
1 reply 0 retweets 0 likes -
Replying to @oli_obk @mgattozzi
You're still using a closure closing over arguments of an unknown type, you can't turn that into a `fn` pointer in a useful way?
1 reply 0 retweets 0 likes -
Replying to @sgrif @mgattozzi
arguments are irrelevant as long as you don't capture anything.
1 reply 0 retweets 0 likes -
-
Replying to @sgrif @mgattozzi
functions are global and thus don't count as capturing. You can access any other `static` from a closure and it is still castable to a function pointer. Only things captured from a runtime scope need to be considered as capturable
1 reply 0 retweets 0 likes
I can't seem to get it to work. What am I missing? https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b18b70f4bfd9adf3f5c5b107f37c4243 …
-
-
Replying to @sgrif @mgattozzi
I think I was misunderstanding what was being done. I assumed that the `vec`'s contents were known at compile-time: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=8e242264d859c8ff6a1d2c80110b7a57 …
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.