Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 1.04 KB

README.md

File metadata and controls

43 lines (30 loc) · 1.04 KB

rusty-perl

Call Rust from Perl with libffi

I wanted to call Rust from Perl and I found this blog post by @pwoolcoc which talks about exactly that (as well as doing the same thing from Julia). It was written a couple of years ago, though, so it predates the release of Rust 1.0. Thus, I had to change a few things to get it to work. This repo contains those things.

Clone this repository.

git clone https://github.com/oylenshpeegul/rusty-perl.git
cd rusty-perl

Run tests.

cargo test

Build a debug version.

cargo build

Now we can try the Perl script with debug set (the 1).

$ perl/points.pl 1
The distance from (2,2) to (4,4) is 2.82842712474619 (the square root of 8).

Build a release version.

cargo build --release

Now we can try the Perl script without the extra argument.

$ perl/points.pl
The distance from (2,2) to (4,4) is 2.82842712474619 (the square root of 8).