Trying to implement i2c for a shared i2c bus behind an async mutex yielded lots of cursed lifetime errors, because &'a mut [Operation<'b>] is invariant on 'b, not covariant as one would expect...
To fix this, the GAT future needs two lifetimes. Also counterintuitively, the future must be + 'a, but NOT + 'b. Then AddressMode: 'static is needed because Rust wants annoying where A: 'a bounds otherwise.
The async SPI PR has the same issue, will fix later. #347
With these fixes, implementing i2c on a mutex works nicely now:
Trying to implement i2c for a shared i2c bus behind an async mutex yielded lots of cursed lifetime errors, because
&'a mut [Operation<'b>]
is invariant on'b
, not covariant as one would expect...To fix this, the GAT future needs two lifetimes. Also counterintuitively, the future must be
+ 'a
, but NOT+ 'b
. ThenAddressMode: 'static
is needed because Rust wants annoyingwhere A: 'a
bounds otherwise.The async SPI PR has the same issue, will fix later. #347
With these fixes, implementing i2c on a mutex works nicely now:
cc @matoushybl