From 0eedec560cc39231c3475535176abf29a04c98f1 Mon Sep 17 00:00:00 2001 From: Damien Grassart Date: Fri, 12 Sep 2014 09:03:15 +0200 Subject: [PATCH 1/2] The example code uses trigger_callback(), not do_callback(). --- src/doc/guide-ffi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md index dd35a610e15..237cc86e51d 100644 --- a/src/doc/guide-ffi.md +++ b/src/doc/guide-ffi.md @@ -243,7 +243,7 @@ void trigger_callback() { } ~~~~ -In this example Rust's `main()` will call `do_callback()` in C, +In this example Rust's `main()` will call `trigger_callback()` in C, which would, in turn, call back to `callback()` in Rust. From d4b2edc3eeaa5b5fd4f83533c7ffe9f56744ba55 Mon Sep 17 00:00:00 2001 From: Damien Grassart Date: Fri, 12 Sep 2014 09:10:03 +0200 Subject: [PATCH 2/2] Use a space after colons per the Rust coding style: https://github.com/rust-lang/rust-guidelines/blob/master/style/whitespace.md --- src/doc/guide-ffi.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md index 237cc86e51d..14e60b5ba08 100644 --- a/src/doc/guide-ffi.md +++ b/src/doc/guide-ffi.md @@ -209,7 +209,7 @@ A basic example is: Rust code: ~~~~no_run -extern fn callback(a:i32) { +extern fn callback(a: i32) { println!("I'm called from C with value {0}", a); } @@ -269,7 +269,7 @@ struct RustObject { // other members } -extern "C" fn callback(target: *mut RustObject, a:i32) { +extern "C" fn callback(target: *mut RustObject, a: i32) { println!("I'm called from C with value {0}", a); unsafe { // Update the value in RustObject with the value received from the callback