use std::fmt::Debug; use ridicule::mock; trait SomeFoobar { fn do_something(&self) -> bool; } trait Foo { fn bar(&self, num: u128) -> Baz; fn biz(&self, fiz: Fiz) -> &Bar; fn baz(&self, name: &str, foobar: Foobar) where Foobar: SomeFoobar + Debug; } mock! { MockFoo {} impl Foo for MockFoo { fn bar(&self, num: u128) -> Baz; fn biz<'a, Fiz: Debug, Bar>(&'a self, fiz: Fiz) -> &'a Bar; fn baz(&self, name: &str, foobar: Foobar) where Foobar: SomeFoobar + Debug; } } fn main() { let mut mock_foo = MockFoo::new(); mock_foo.expect_bar().returning(|_me, num| { println!("bar was called with {num}"); "Hello".to_string() }); mock_foo.expect_bar::().returning(|_me, num| { println!("bar was called with {num}"); 136322 }); assert_eq!(mock_foo.bar::(123), "Hello".to_string()); assert_eq!(mock_foo.bar::(456), 136322); }