]> git.lizzy.rs Git - rust.git/commitdiff
hack to make example compile
authorAlex Burka <durka42+github@gmail.com>
Tue, 14 Jun 2016 19:53:55 +0000 (15:53 -0400)
committerAlex Burka <aburka@seas.upenn.edu>
Wed, 27 Jul 2016 17:58:51 +0000 (13:58 -0400)
src/doc/book/ffi.md

index e63516e58ccfdb213128a59b028273b86c5b2536..e1b9789a3144af6e245c8ae5ff35c5006decdd37 100644 (file)
@@ -598,17 +598,21 @@ we have function pointers flying across the FFI boundary in both directions.
 ```rust
 use std::os::raw::c_int;
 
+# #[cfg(hidden)]
 extern "C" {
     /// Register the callback.
     fn register(cb: Option<extern "C" fn(Option<extern "C" fn(c_int) -> c_int>, c_int) -> c_int>);
 }
+# unsafe fn register(_: Option<extern "C" fn(Option<extern "C" fn(c_int) -> c_int>,
+#                                            c_int) -> c_int>)
+# {}
 
 /// This fairly useless function receives a function pointer and an integer
 /// from C, and returns the result of calling the function with the integer.
 /// In case no function is provided, it squares the integer by default.
 extern "C" fn apply(process: Option<extern "C" fn(c_int) -> c_int>, int: c_int) -> c_int {
     match process {
-        Some(f) => unsafe { f(int) },
+        Some(f) => f(int),
         None    => int * int
     }
 }