pub struct Clause(_);
Expand description
A clause from which unimock instances are created.
There can be more than one clause for each MockFn instance, these will be combined together at construction time.
Clause is non-generic and uses dynamic dispatch internally.
It also implements From<I> where I: IntoIterator<Item = Clause>
, so one clause can contain several other clauses in a hierarchical manner.
This means that clauses can be returned from helper functions and reused several times:
use unimock::*;
#[unimock]
trait Foo {
fn foo(&self, i: i32) -> i32;
}
#[unimock]
trait Bar {
fn bar(&self, i: i32) -> i32;
}
#[unimock]
trait Baz {
fn baz(&self, i: i32) -> i32;
}
// reusable function
fn foo_bar_setup_clause() -> Clause {
[
Foo__foo.each_call(matching!(_)).returns(1).in_any_order(),
Bar__bar.each_call(matching!(_)).returns(2).in_any_order(),
]
.into()
}
let unimock = mock([
foo_bar_setup_clause(),
Baz__baz.each_call(matching!(_)).returns(3).in_any_order()
]);
assert_eq!(6, unimock.foo(0) + unimock.bar(0) + unimock.baz(0));
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Clause
impl Send for Clause
impl Sync for Clause
impl Unpin for Clause
impl !UnwindSafe for Clause
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