how to store Futures from 2 different async functions with equal signatures in vector?
i have 2 functions in different crates:
crate 1:
pub async fn resolve(
client: &String,
site: &String,
id: &String,
) -> Result<String, Box<dyn std::error::Error>> {
...
return Ok("".parse().unwrap());
}
crate 2:
pub async fn resolve(
client: &String,
site: &String,
id: &String,
) -> Result<String, Box<dyn std::error::Error>> {
...
return Ok("".parse().unwrap());
}
and i tried to aggregate results of functions calls like so:
let mut futures : Vec<_> = Vec::new();
for i in 0..self.settings.count {
futures.push(
crate1::resolve(
&self.settings.filed1,
&self.settings.filed2,
&product.id,
)
);
futures.push(
crate2::resolve(
&self.settings.filed1,
&self.settings.filed2,
&product.id,
)
);
}
but i got this:
error[E0308]: mismatched types
--> src\client.rs:124:17
|
124 | / crate2::resolve(
125 | | &self.settings.filed1,
126 | | &self.settings.filed2,
127 | | &product.id,
128 | | )
| |_________________^ expected opaque type, found a different opaque type
|
note: while checking the return type of the `async fn`
--> src\crate1.rs:97:6
|
97 | ) -> Result<String, Box<dyn std::error::Error>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type
note: while checking the return type of the `async fn`
--> src\crate2.rs:17:6
|
17 | ) -> Result<String, Box<dyn std::error::Error>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, found opaque type
= note: expected opaque type `impl futures::Future` (opaque type at <src\crate1.rs:97:6>)
found opaque type `impl futures::Future` (opaque type at <src\crate2.rs:17:6>)
= help: consider `await`ing on both `Future`s
= note: distinct uses of `impl Trait` result in different opaque types
why rust can't deduce type?