Closed audunhalland closed 1 year ago
Based on external feedback, the best way to do this is not to put any auto-generated names into scope, this is unhygienic. Instead, force the user name the API. This has already been done in Unimock 0.4
. Unimock's API is #[unimock(api=MyApi)}
. Entrait's API will be #[entrait(Foo, mock_api=MyMockApi)}
.
Currently, the naming of generated unimock types is very inconsistent:
MockFn
path#[entrait(Foo)] fn foo() {}
foo
foo::Fn
#[entrait(Foo)] mod foo { fn bar() {} }
foo
foo::bar::Fn
#[entrait] trait Foo { fn bar() }
Foo__bar
I wish to make these more consistent. The way
Mockall
does it seems better: always make someMock*
struct that represents the mockable trait.This is the suggestion:
MockFn
path#[entrait(Foo)] fn foo() {}
MockFoo
MockFoo()
#[entrait(Foo)] mod foo { fn bar() {} }
MockFoo
MockFoo::bar()
#[entrait] trait Foo { fn bar(); }
MockFoo
MockFoo::bar()
This should be part of the next major version of unimock (0.4), where the defaults will be changed from
Foo__bar
toFoo::bar()