-
-
Save RayMPerry/90da6c767d2327678d33a80fa3c2248c to your computer and use it in GitHub Desktop.
Raku-Rust Nativecall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { * }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[no_mangle] | |
pub extern fn add(number1: u32, number2: u32) -> u32 { | |
number1 + number2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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