Closed JanzenJohn closed 1 month ago
You've defined your function as returning something that isn't Send
. Try this instead:
mock! {
#[derive(Debug)]
pub Subscriber {
pub fn next(&self) -> impl Future<Output=Option<Message>> + Send;
}
}
that works, i didn't expect that the return of the function could impact if the Mock itself is send
I'm trying to mock a struct with several "Subscribers" which all have an async next() method.
But i only want to fire some in a given text, the others should return a
futures::future::pending()
. The solution i saw around for returning futures was to exchange the async await syntax for impl Future syntax so my mock! looks like thisthe expectation is built like this
But if i try to move this struct into another thread i get a compiler error
Do i need to implement the returning of futures differently? Or is there another way to make a mocked async function return a pending future?