I encountered a compiler bug which is similar to this post, and I would like to give the closure explicit type annotation to workaround it as @Yandros wrote:
Either you tweak your types / etc. (e.g., by massaging the callback's signature so that it becomes properly higher-order?) into now being able to meet this more demanding higher-order constraint
In the linked post, the code snippet that trigger the compiler bug is:
use futures::{stream, StreamExt, TryStreamExt};
use reqwest::Client;
async fn run() -> Vec<String> {
let client = &Client::new();
stream::iter(["asdf", "qwer"])
.map(|s| async move {
let resp = client.get(format!("https://httpbin.org/get?{s}")).send().await?;
resp.text().await
})
.buffer_unordered(10)
.try_collect().await.unwrap()
}
And I would like to give an explicit type annotation (with HKTB) to this closure, but don't know how to write it.
|s| async move {
let resp = client.get(format!("https://httpbin.org/get?{s}")).send().await?;
resp.text().await
}