Skip to content

Instantly share code, notes, and snippets.

@RayMPerry
Created October 15, 2021 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RayMPerry/90da6c767d2327678d33a80fa3c2248c to your computer and use it in GitHub Desktop.
Save RayMPerry/90da6c767d2327678d33a80fa3c2248c to your computer and use it in GitHub Desktop.
Raku-Rust Nativecall
use NativeCall;
unit module AdditionLib;
constant LIBRARY_PATH = IO::Path.new: "addition/lib/release";
constant LIBRARY_NAME = "addition";
sub add(int32, int32 --> int32) is native(LIBRARY_PATH.add(LIBRARY_NAME).path) is export { * };
#[no_mangle]
pub extern fn add(number1: u32, number2: u32) -> u32 {
number1 + number2
}
use lib "lib";
use AdditionLib;
for 1..100 -> $firstNumber, $secondNumber {
say add($firstNumber, $secondNumber);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment