nrxus / faux

Struct mocking library for Rust
https://nrxus.github.io/faux/
MIT License
411 stars 14 forks source link

Use per-mock mutexes in MockStore #36

Closed Wesmania closed 3 years ago

Wesmania commented 3 years ago

This makes mocks no longer panic, while making sure that calling individual mocked methods does not lock the entire mock. For convenience, the mutex is moved inside MockStore.

Fixes #35.

Signed-off-by: Igor Kotrasinski i.kotrasinsk@gmail.com

nrxus commented 3 years ago

Ah thank you so much! This totally works!

I had forgotten that I had implemented an "Exhausted" state to the mocks so they didn't get "consumed" anymore, it is always just by &mut which lets you do the Mutex<Arc<Mock>>!

I will be merging this soon, I just want to make sure I fully grok it first (:

nrxus commented 3 years ago

I did some minor cosmetic tweaks to the tests, mostly for my own benefit for readability later (:

Thanks a lot!