Add Rust to C example

This commit is contained in:
Alex Crichton
2015-04-19 10:07:11 -07:00
commit afbdb0cc41
5 changed files with 32 additions and 0 deletions

11
rust-to-c/src/main.rs Normal file
View File

@@ -0,0 +1,11 @@
extern crate libc;
extern {
fn double_input(input: libc::c_int) -> libc::c_int;
}
fn main() {
let input = 4;
let output = unsafe { double_input(input) };
println!("{} * 2 = {}", input, output);
}