Skip to content

Commit 103a2b5

Browse files
authored
Merge pull request #171 from danielhenrymantilla/master
[function pointers example] Marked the function pointer and exported function as `unsafe`
2 parents 1c44b54 + fc24899 commit 103a2b5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

reference/src/layout/function-pointers.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ pub extern "C" fn cons(node: Option<Box<Cons>>, data: c_int) -> Box<Cons> {
9797
}
9898
9999
#[no_mangle]
100-
pub extern "C" fn iterate(
100+
pub unsafe extern "C" fn iterate(
101101
node: Option<&Cons>,
102-
func: extern fn(i32, *mut c_void), // note - non-nullable
102+
func: unsafe extern "C" fn(i32, *mut c_void), // note - non-nullable
103103
thunk: *mut c_void, // note - this is a thunk, so it's just passed raw
104104
) {
105105
let mut it = node;
@@ -110,9 +110,9 @@ pub extern "C" fn iterate(
110110
}
111111
112112
#[no_mangle]
113-
pub extern "C" fn for_all(
113+
pub unsafe extern "C" fn for_all(
114114
node: Option<&Cons>,
115-
func: extern fn(i32, *mut c_void) -> bool,
115+
func: unsafe extern "C" fn(i32, *mut c_void) -> bool,
116116
thunk: *mut c_void,
117117
) -> bool {
118118
let mut it = node;

0 commit comments

Comments
 (0)