Add Ruby to Rust example
This commit is contained in:
11
ruby-to-rust/src/main.rb
Normal file
11
ruby-to-rust/src/main.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'ffi'
|
||||
|
||||
module Hello
|
||||
extend FFI::Library
|
||||
ffi_lib 'target/libdouble_input.so'
|
||||
attach_function :double_input, [ :int ], :int
|
||||
end
|
||||
|
||||
input = 4
|
||||
output = Hello.double_input(input)
|
||||
puts "#{input} * 2 = #{output}"
|
||||
Reference in New Issue
Block a user