2016-06-08 06:43:34 -05:00
|
|
|
fn f() -> i32 {
|
|
|
|
42
|
|
|
|
}
|
|
|
|
|
|
|
|
fn return_fn_ptr() -> fn() -> i32 {
|
|
|
|
f
|
|
|
|
}
|
|
|
|
|
|
|
|
fn call_fn_ptr() -> i32 {
|
|
|
|
return_fn_ptr()()
|
|
|
|
}
|
|
|
|
|
2016-06-13 07:27:05 -05:00
|
|
|
fn main() {
|
|
|
|
assert_eq!(call_fn_ptr(), 42);
|
2016-06-20 03:35:15 -05:00
|
|
|
assert!(return_fn_ptr() == f);
|
|
|
|
assert!(return_fn_ptr() as unsafe fn() -> i32 == f as fn() -> i32 as unsafe fn() -> i32);
|
2016-06-13 07:27:05 -05:00
|
|
|
}
|