use ridicule::mock; trait Foo: Sized { fn bar(&self, num: u128) -> &Self; } mock! { MockFoo {} impl Foo for MockFoo { fn bar(&self, num: u128) -> &Self; } } fn main() { let mut mock_foo = MockFoo::new(); mock_foo.expect_bar().returning(|me, num| { println!("bar was called with {num}"); me }); mock_foo.bar(123); }