Skip to content

Instantly share code, notes, and snippets.

@euphoria
Created July 16, 2014 21:38
Show Gist options
  • Save euphoria/004005c8a6a9cb7f1183 to your computer and use it in GitHub Desktop.
Save euphoria/004005c8a6a9cb7f1183 to your computer and use it in GitHub Desktop.
$ rustc --crate-type dylib rusty.rs
$ python rusty.py
5
from cffi import FFI
ffi = FFI()
ffi.cdef("""
int rusty_sum(int x, int y);
""")
rusty_lib = ffi.dlopen('librusty.so')
result = rusty_lib.rusty_sum(2, 3)
print result
#[no_mangle]
pub extern fn rusty_sum(x: int, y: int) -> int {
x + y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment