pub struct Unimock { /* private fields */ }
Expand description
Unimock stores a collection of mock objects, with the end goal of implementing all the mocked traits. The trait implementaion is achieved through using the unimock macro.
Implementations
sourceimpl Unimock
impl Unimock
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty Unimock. Attempting to call implemented traits on an empty instance will panic at runtime.
sourcepub fn mock<M, F>(self, f: F) -> Self where
M: Default + Send + Sync + 'static,
F: FnOnce(&mut M),
pub fn mock<M, F>(self, f: F) -> Self where
M: Default + Send + Sync + 'static,
F: FnOnce(&mut M),
Configure a specific mock. The type must implement Default. Each stored mock is keyed by its TypeId, so repeatedly calling this method with the same receiving type will use the same instance.
When a trait is mocked using unimock, its mocked implementation must be used in this function.
Example
use unimock::*;
#[unimock]
trait MyTrait {}
let unimock = Unimock::new().mock(|my_trait: &mut MockMyTrait| {
/* ... */
});
Auto Trait Implementations
impl !RefUnwindSafe for Unimock
impl Send for Unimock
impl Sync for Unimock
impl Unpin for Unimock
impl !UnwindSafe for Unimock
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more