perl-to-rust
This commit is contained in:
4
perl-to-rust/src/lib.rs
Normal file
4
perl-to-rust/src/lib.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
#[no_mangle]
|
||||
pub extern fn double_input(input: i32) -> i32 {
|
||||
input * 2
|
||||
}
|
||||
14
perl-to-rust/src/main.pl
Normal file
14
perl-to-rust/src/main.pl
Normal file
@@ -0,0 +1,14 @@
|
||||
use v5.10;
|
||||
use FFI::Raw;
|
||||
|
||||
my $double_input = FFI::Raw->new(
|
||||
"target/libdouble_input.so",
|
||||
'double_input',
|
||||
FFI::Raw::int, # return value
|
||||
FFI::Raw::int # arg #1
|
||||
);
|
||||
|
||||
my $input = 4;
|
||||
my $output = $double_input->call($input);
|
||||
say $input . " * 2 = " . $output;
|
||||
|
||||
Reference in New Issue
Block a user