Add Python to Rust example

This commit is contained in:
Alex Crichton
2015-04-19 10:44:03 -07:00
parent 515ebb2db1
commit e37bd54df4
4 changed files with 29 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
#[no_mangle]
pub extern fn double_input(input: i32) -> i32 {
input * 2
}

View File

@@ -0,0 +1,8 @@
from ctypes import cdll
lib = cdll.LoadLibrary('target/libdouble_input.so')
double_input = lib.double_input
input = 4
output = double_input(input)
print(str(input) + " * 2 = " + str(output))