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

Create a new, empty Unimock. Attempting to call implemented traits on an empty instance will panic at runtime.

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| {
    /* ... */
});

Get a specific mock created with mock. Panics at runtime if the type is not registered.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.