Closed
Description
pub trait SpiDevice {
async fn transaction<'a, F: 'a>(&'a mut self, f: F);
}
impl SpiDevice for () {
async fn transaction<'a, F: 'a>(&'a mut self, f: F) {}
}
gives the following error:
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): method not compatible with trait
--> src/lib.rs:9:5
|
9 | async fn transaction<'a, F: 'a>(&'a mut self, f: F) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
note: while checking the return type of the `async fn`
--> src/lib.rs:9:57
|
9 | async fn transaction<'a, F: 'a>(&'a mut self, f: F) {}
| ^ checked the `Output` of this `async fn`, expected opaque type
note: while checking the return type of the `async fn`
--> src/lib.rs:9:57
|
9 | async fn transaction<'a, F: 'a>(&'a mut self, f: F) {}
| ^ checked the `Output` of this `async fn`, found opaque type
= note: expected fn pointer `fn(&'a mut (), _) -> impl Future<Output = ()>`
found fn pointer `fn(&'a mut (), _) -> impl Future<Output = ()>`
note: the lifetime `'a` as defined here...
--> src/lib.rs:9:26
|
9 | async fn transaction<'a, F: 'a>(&'a mut self, f: F) {}
| ^^
= note: ...does not necessarily outlive the static lifetime
The equivalent without async
works.