diff options
Diffstat (limited to 'examples/simple.rs')
-rw-r--r-- | examples/simple.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/examples/simple.rs b/examples/simple.rs index a5b7203..cb6feb9 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -19,14 +19,14 @@ trait Foo } mock! { - MockFoo; + MockFoo {} impl Foo for MockFoo { - fn bar<Baz>(self: (&Self), num: u128) -> Baz; + fn bar<Baz>(&self, num: u128) -> Baz; - fn biz<Fiz: (Debug +), Bar>(self: (&Self), fiz: Fiz) -> &Bar; + fn biz<'a, Fiz: Debug, Bar>(&'a self, fiz: Fiz) -> &'a Bar; - fn baz<Foobar>(self: (&Self), name: &str, foobar: Foobar) + fn baz<Foobar>(&self, name: &str, foobar: Foobar) where Foobar: SomeFoobar + Debug; } @@ -38,7 +38,17 @@ fn main() mock_foo.expect_bar().returning(|_me, num| { println!("bar was called with {num}"); + + "Hello".to_string() + }); + + mock_foo.expect_bar::<u128>().returning(|_me, num| { + println!("bar was called with {num}"); + + 136322 }); - mock_foo.bar::<()>(123); + assert_eq!(mock_foo.bar::<String>(123), "Hello".to_string()); + + assert_eq!(mock_foo.bar::<u128>(456), 136322); } |