-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use generic argument/return type with lifetime bound #216
Comments
Unsurprising. Lifetime arguments are a real viper's nest. What happens if you write it like this? use mockall::automock;
trait Foo<'a> {}
#[automock]
trait Bar {
fn bar<'a, F: Foo<'a>>(&self, foo: F);
} |
That code appears to fail with the same errors |
This is harder than I expected, thanks to that Generic. Mockall uses downcasting to handle generic methods, and Rust's trait Bar {
fn bar<'a, F: Foo<'a>>(&self, foo: F);
}
mock! {
Boo { }
Bar {
pub fn bean<'a>(&self, foo: &dyn Foo<'a>);
}
}
impl Bar for MockBoo {
fn bar<'a, F: Foo<'a>>(&self, foo: F) {
self.bean(&foo)
}
} |
Closing this issue in favor of the more general #217 . |
When trying to mock a method that has a generic argument or return type that is bound by a generic lifetime, automock can't seem to generate the correct code:
This fails to compile with these errors:
The text was updated successfully, but these errors were encountered: