From fc24899dbb221465ef54f74430f380a8013f81d7 Mon Sep 17 00:00:00 2001 From: danielhenrymantilla Date: Sun, 21 Jul 2019 22:02:41 +0200 Subject: [PATCH] Added unsafe to function pointers FFI example --- reference/src/layout/function-pointers.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reference/src/layout/function-pointers.md b/reference/src/layout/function-pointers.md index 3188fb05..5e842e10 100644 --- a/reference/src/layout/function-pointers.md +++ b/reference/src/layout/function-pointers.md @@ -97,9 +97,9 @@ pub extern "C" fn cons(node: Option>, data: c_int) -> Box { } #[no_mangle] -pub extern "C" fn iterate( +pub unsafe extern "C" fn iterate( node: Option<&Cons>, - func: extern fn(i32, *mut c_void), // note - non-nullable + func: unsafe extern "C" fn(i32, *mut c_void), // note - non-nullable thunk: *mut c_void, // note - this is a thunk, so it's just passed raw ) { let mut it = node; @@ -110,9 +110,9 @@ pub extern "C" fn iterate( } #[no_mangle] -pub extern "C" fn for_all( +pub unsafe extern "C" fn for_all( node: Option<&Cons>, - func: extern fn(i32, *mut c_void) -> bool, + func: unsafe extern "C" fn(i32, *mut c_void) -> bool, thunk: *mut c_void, ) -> bool { let mut it = node;