Struct mimicry::RealCallSwitch

source ·
pub struct RealCallSwitch(_);
Expand description

Switch between real and mocked implementations.

A field of this type should be present on a struct for #[derive(CallReal)] to work.

Examples

#[derive(Mock, CallReal)]
struct MockState {
    // other fields...
    _switch: RealCallSwitch,
}

// You can now use `CallReal` methods in mock logic:
impl MockState {
    fn mock_something(&self, arg: &str) {
        self.call_real().scope(|| { /* ... */ });
    }
}

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

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.