-
Notifications
You must be signed in to change notification settings - Fork 19
Description
aa18c66 allowed mocks to be Send/Sync by forcing the user only provide Send closures, and using Mutex instead of RefCell for the interior mutability of the MockStore.
While this is fine as an MVP to allow mocking structs in Send/Sync contexts, it is very much the opposite of an "zero cost abstraction" (TM). Now every user has to pay the cost of making sure their captured variables are always Send, and the performance implication of Mutex even when they do not care/need their mocks to be Send/Sync.
This is far from ideal.
Suggestion:
An attribute to #[faux::create] and #[faux::methods] that specify if they need a sync/send.
This can get annoying if you are always mocking sync/send structs (i.e., you are building an API in Rocket which forces the request guards to be Send/Sync and you want to mock the request guards). I think a feature turn in on crate-wide would reduce this pain.