Closed avysk closed 7 months ago
What am I doing incorrectly?
Nothing. This is a limitation of Rust and its lifetime system. Basically, Mockall needs for a mocked method's return value to be 'static
. There are a few exceptions, for things like returning a reference. But supporting additional patterns like Option<&T>
would require special code for every possible pattern.
I'm going to close this bug as a duplicate of #387 . You can see a workaround there.
Hello,
I have the following problem. I wonder what I am doing incorrectly. Here is the working code:
This can be run and it prints, of course,
None Some("ar")
. Now I add in the beginning some lines:with the intention to make trait
Foo
mockable. However, the thing explodes:Removing
&Self
usage from the trait helps. The following compiles and works:Just in case my
Cargo.toml
:What am I doing incorrectly?