Skip to content
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

Struct with different traits that has identically named methods #551

Open
ThomasConrad opened this issue Feb 23, 2024 · 1 comment
Open
Labels
question Usage question

Comments

@ThomasConrad
Copy link

Let say I want to mock a struct like this:

mock!(
Foo {}
impl A for Foo {
  fn new(&self) -> A;
}
impl B for Foo {
  fn new(&self) -> B;
} 
);

Then I am getting an error saying that expect_new() is already defined. I would strongly prefer the created method to be named something like expect_A_new(), you get the point.

@asomers asomers added the question Usage question label Feb 23, 2024
@asomers
Copy link
Owner

asomers commented Feb 23, 2024

This name collision is a well known problem, and there's no setting in Mockall that can fix it for you. You'll have to manually mock one of those methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usage question
Projects
None yet
Development

No branches or pull requests

2 participants