summaryrefslogtreecommitdiff
path: root/examples/generic_fn_method.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-04-01 15:27:09 +0200
committerHampusM <hampus@hampusmat.com>2023-04-01 15:27:09 +0200
commit5eb823896f01146df0d4ed6c296ef7dd445ccbbf (patch)
tree482ba87a3977f646dcff956affd47dac50a2d647 /examples/generic_fn_method.rs
parentba865b581fbc1d0589b402b028f2bce70332891b (diff)
fix: make expectation returning method unsafe
Diffstat (limited to 'examples/generic_fn_method.rs')
-rw-r--r--examples/generic_fn_method.rs32
1 files changed, 18 insertions, 14 deletions
diff --git a/examples/generic_fn_method.rs b/examples/generic_fn_method.rs
index 7cf0d78..3330269 100644
--- a/examples/generic_fn_method.rs
+++ b/examples/generic_fn_method.rs
@@ -32,25 +32,29 @@ fn main()
{
let mut mock_foo = MockFoo::new();
- mock_foo
- .expect_do_something()
- .returning(|_me, cb: fn(_) -> _| {
- println!("do_something was called");
+ unsafe {
+ mock_foo
+ .expect_do_something()
+ .returning(|_me, cb: fn(_) -> _| {
+ println!("do_something was called");
- let cb_res = cb(42);
+ let cb_res = cb(42);
- println!("Received '{cb_res}' from callback");
- });
+ println!("Received '{cb_res}' from callback");
+ });
+ }
- mock_foo
- .expect_do_something_else()
- .returning(|_me, cb: fn(_) -> PathBuf| {
- println!("do_something_else was called");
+ unsafe {
+ mock_foo
+ .expect_do_something_else()
+ .returning(|_me, cb: fn(_) -> PathBuf| {
+ println!("do_something_else was called");
- let cb_res = cb(255.255);
+ let cb_res = cb(255.255);
- println!("Received '{}' from callback", cb_res.display());
- });
+ println!("Received '{}' from callback", cb_res.display());
+ });
+ }
mock_foo.do_something((|num| format!("Hello there {num}")) as fn(_) -> _);