diff options
Diffstat (limited to 'examples/generic_method.rs')
-rw-r--r-- | examples/generic_method.rs | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/examples/generic_method.rs b/examples/generic_method.rs index c4e3214..c86864d 100644 --- a/examples/generic_method.rs +++ b/examples/generic_method.rs @@ -39,31 +39,35 @@ fn main() { let mut mock_foo = MockFoo::new(); - mock_foo - .expect_bar::<u16>() - .returning(|_me, num| { + unsafe { + mock_foo.expect_bar::<u16>().returning(|_me, num| { println!("bar was called with {num}"); "Hello".to_string() }) - .times(3); - - mock_foo.expect_bar::<&str>().returning(|_me, num| { - println!("bar was called with {num}"); - - 128u8 - }); - - mock_foo - .expect_abc::<&str, f64>() - .with( - function(|thing_a: &&str| thing_a.starts_with("Good morning")), - is_close(7.13081), - ) - .returning(|_me, _thing_a, _thing_b| { - println!("abc was called"); - }) - .times(1); + } + .times(3); + + unsafe { + mock_foo.expect_bar::<&str>().returning(|_me, num| { + println!("bar was called with {num}"); + + 128u8 + }); + } + + unsafe { + mock_foo + .expect_abc::<&str, f64>() + .with( + function(|thing_a: &&str| thing_a.starts_with("Good morning")), + is_close(7.13081), + ) + .returning(|_me, _thing_a, _thing_b| { + println!("abc was called"); + }) + } + .times(1); assert_eq!(mock_foo.bar::<u16>(123), "Hello".to_string()); assert_eq!(mock_foo.bar::<u16>(123), "Hello".to_string()); |