cffi + rust

Basic example to call a rust function with the help of CFFI Package.

rust2cffi.rs :

// Specifies the type of crate.
#![crate_type = "dylib"]
// Specifies the crate name.
#![crate_name = "rust2cffi"]
// Disables symbol name encoding.
#[no_mangle]
// compile: rustc rust2cffi.rs

pub extern fn mul(value1: i32, value2: i32) -> i32 {
    value1 * value2
}

rust2cffi.tcl

package require cffi

cffi::Wrapper create RUST2CFFI librust2cffi[info sharedlibextension]
# call rust function...
RUST2CFFI function mul int {value1 int value2 int}

puts [mul 3 3]