Skip to content

Commit 54ecc21

Browse files
committed
hack to make example compile
1 parent 5276b29 commit 54ecc21

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/doc/book/ffi.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,21 @@ we have function pointers flying across the FFI boundary in both directions.
598598
```rust
599599
use std::os::raw::c_int;
600600

601+
# #[cfg(hidden)]
601602
extern "C" {
602603
/// Register the callback.
603604
fn register(cb: Option<extern "C" fn(Option<extern "C" fn(c_int) -> c_int>, c_int) -> c_int>);
604605
}
606+
# unsafe fn register(_: Option<extern "C" fn(Option<extern "C" fn(c_int) -> c_int>,
607+
# c_int) -> c_int>)
608+
# {}
605609

606610
/// This fairly useless function receives a function pointer and an integer
607611
/// from C, and returns the result of calling the function with the integer.
608612
/// In case no function is provided, it squares the integer by default.
609613
extern "C" fn apply(process: Option<extern "C" fn(c_int) -> c_int>, int: c_int) -> c_int {
610614
match process {
611-
Some(f) => unsafe { f(int) },
615+
Some(f) => f(int),
612616
None => int * int
613617
}
614618
}

0 commit comments

Comments
 (0)