Closed Wesmania closed 3 years ago
I have this minimal example:
#[cfg(test)] use mocktopus::macros::*; pub struct Foo { } #[cfg_attr(test, mockable)] impl Foo { pub async fn read(&mut self, buf: &mut[u8]) { let _ = buf; } }
It builds fine without tests, but fails with tests enabled with:
error[E0621]: explicit lifetime required in the type of `buf` --> src/main.rs:13:5 | 12 | pub async fn read(&mut self, buf: &mut[u8]) -> () | -------- help: add explicit lifetime `'mocktopus` to the type of `buf`: `&'mocktopus mut [u8]` 13 | / { 14 | | let _ = buf; 15 | | } | |_____^ lifetime `'mocktopus` required
Using pub async fn read<'a>(&mut self, buf: &'a mut[u8]) instead silences the error. I have no idea if it's a good workaround.
pub async fn read<'a>(&mut self, buf: &'a mut[u8])
I have this minimal example:
It builds fine without tests, but fails with tests enabled with:
Using
pub async fn read<'a>(&mut self, buf: &'a mut[u8])
instead silences the error. I have no idea if it's a good workaround.