mockall icon indicating copy to clipboard operation
mockall copied to clipboard

Struct with different traits that has identically named methods

Open ThomasConrad opened this issue 1 year ago • 1 comments

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.

ThomasConrad avatar Feb 23 '24 10:02 ThomasConrad

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.

asomers avatar Feb 23 '24 13:02 asomers