Skip to content

[function pointers example] Marked the function pointer and exported function as unsafe #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions reference/src/layout/function-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ pub extern "C" fn cons(node: Option<Box<Cons>>, data: c_int) -> Box<Cons> {
}

#[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;
Expand All @@ -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;
Expand Down