You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use async_trait::async_trait; // 0.1.36
use tokio; // 0.2.21
#[async_trait]
trait MyTrait {
async fn blah(&self, values: impl Iterator<Item = i32> + Send + 'async_trait) {
println!("this is the default");
}
}
struct S;
#[async_trait]
impl MyTrait for S {
async fn blah(&self, values: impl Iterator<Item = i32> + Send + 'async_trait) {
for value in values {
println!("{}", value);
}
}
}
#[tokio::main]
async fn main() {
let s = S;
s.blah([1, 2, 3].iter().cloned()).await;
}
this fails to compile with the error:
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> src/main.rs:4:1
|
4 | #[async_trait]
| ^^^^^^^^^^^^^^ explicit generic argument not allowed
|
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
If I remove the default body, it works.
Is this intended to be supported? I can work around it by boxing and using dyn, i.e. values: Box<dyn Iterator<Item=i32> + Send + 'async_trait> but that's not ideal.
Thanks for this crate!
The text was updated successfully, but these errors were encountered:
and rustc does not like the explicit generic argument in __blah::<Self>(self, values). Simply removing that ::<Self> turbofish works for this case at least.
Given the code:
this fails to compile with the error:
If I remove the default body, it works.
Is this intended to be supported? I can work around it by boxing and using
dyn
, i.e.values: Box<dyn Iterator<Item=i32> + Send + 'async_trait>
but that's not ideal.Thanks for this crate!
The text was updated successfully, but these errors were encountered: