Expand description
A matched call pattern, ready for setting up a response.
Implementations
sourceimpl<'p, F, O> Match<'p, F, O> where
F: MockFn + 'static,
O: Ordering,
impl<'p, F, O> Match<'p, F, O> where
F: MockFn + 'static,
O: Ordering,
sourcepub fn returns(self, value: impl Into<F::Output>) -> QuantifyResponse<'p, F, O> where
F::Output: Send + Sync + Clone + 'static,
pub fn returns(self, value: impl Into<F::Output>) -> QuantifyResponse<'p, F, O> where
F::Output: Send + Sync + Clone + 'static,
sourcepub fn returns_default(self) -> QuantifyResponse<'p, F, O> where
F::Output: Default,
pub fn returns_default(self) -> QuantifyResponse<'p, F, O> where
F::Output: Default,
Specify the output of the call pattern by calling Default::default()
.
sourcepub fn returns_ref<T>(self, value: T) -> QuantifyResponse<'p, F, O> where
T: Borrow<F::Output> + Sized + Send + Sync + 'static,
pub fn returns_ref<T>(self, value: T) -> QuantifyResponse<'p, F, O> where
T: Borrow<F::Output> + Sized + Send + Sync + 'static,
Specify the output of the call to be a borrow of the provided value.
This works well when the lifetime of the returned reference is the same as self
.
Using this for 'static
references will produce a runtime error. For static references, use Match::returns_static.
sourcepub fn returns_static(
self,
value: &'static F::Output
) -> QuantifyResponse<'p, F, O> where
F::Output: Send + Sync + 'static,
pub fn returns_static(
self,
value: &'static F::Output
) -> QuantifyResponse<'p, F, O> where
F::Output: Send + Sync + 'static,
Specify the output of the call to be a reference to static value.
This must be used when the returned reference in the mocked trait is 'static
.
sourcepub fn answers<A, R>(self, func: A) -> QuantifyResponse<'p, F, O> where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Into<F::Output>,
F::Output: Sized,
pub fn answers<A, R>(self, func: A) -> QuantifyResponse<'p, F, O> where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Into<F::Output>,
F::Output: Sized,
Specify the output of the call pattern by invoking the given closure that can then compute it based on input parameters.
sourcepub fn answers_leaked_ref<A, R>(self, func: A) -> QuantifyResponse<'p, F, O> where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Borrow<F::Output> + 'static,
F::Output: Sized,
pub fn answers_leaked_ref<A, R>(self, func: A) -> QuantifyResponse<'p, F, O> where
A: for<'i> Fn(<F as MockInputs<'i>>::Inputs) -> R + Send + Sync + 'static,
R: Borrow<F::Output> + 'static,
F::Output: Sized,
Specify the output of the call pattern to be a static reference to leaked memory.
The value may be based on the value of input parameters.
This version will produce a new memory leak for every invocation of the answer function.
This method should only be used when computing a reference based on input parameters is necessary, which should not be a common use case.
sourcepub fn panics(self, message: impl Into<String>) -> QuantifyResponse<'p, F, O>
pub fn panics(self, message: impl Into<String>) -> QuantifyResponse<'p, F, O>
Prevent this call pattern from succeeding by explicitly panicking with a custom message.
sourcepub fn unmocked(self) -> QuantifyResponse<'p, F, O> where
F: Unmock,
pub fn unmocked(self) -> QuantifyResponse<'p, F, O> where
F: Unmock,
Instruct this call pattern to invoke the Unmocked function.
Auto Trait Implementations
impl<'p, F, O> !RefUnwindSafe for Match<'p, F, O>
impl<'p, F, O> Send for Match<'p, F, O> where
F: Send,
O: Send,
impl<'p, F, O> Sync for Match<'p, F, O> where
F: Sync,
O: Sync,
impl<'p, F, O> Unpin for Match<'p, F, O> where
F: Unpin,
O: Unpin,
impl<'p, F, O> !UnwindSafe for Match<'p, F, O>
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