run_asset_script("script1.sh", [("NAME", "a name")]).await?;
But it doesn't work when trying to pass an empty array, for a script that doesn't require any env vars:
error[E0698]: type inside `async fn` body must be known in this context
--> src/cjdns.rs:102:13
|
102 | utils::run_asset_script("cjdns_launch.sh", [])
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `impl AsRef<str>` declared on the function `run_asset_script`
|
note: the type is part of the `async fn` body because of this `await`
--> src/cjdns.rs:103:17
|
103 | .await
| ^^^^^^
Why it doesn't work? How could I make it compile, please?
impl Trait in argument position is equivalent to a generic parameter. If the array has no elements, then how is the compiler supposed to infer the concrete item type of the array? You'll have to specify the type explicitly somehow. (That can be cumbersome with impl Trait – use an explicit generic type parameter instead.)
Yes, I can see that, thanks.
But since it is an empty IntoIterator, I wouldn't use anything in that param anyway, there isn't any data to use... So, I'd want it to infer simply anything, it doesn't matter, &str for instance.
Is there any way I can do this?