Add rust extension

This commit is contained in:
2025-03-14 17:51:55 +00:00
parent d47b8ca684
commit 93b925f4c5
11 changed files with 467 additions and 25 deletions
+12
View File
@@ -0,0 +1,12 @@
use magnus::{function, Error, Ruby};
fn distance(a: (f64, f64), b: (f64, f64)) -> f64 {
((b.0 - a.0).powi(2) + (b.1 - a.1).powi(2)).sqrt()
}
#[magnus::init]
fn init(ruby: &Ruby) -> Result<(), Error> {
ruby.define_global_function("distance", function!(distance, 2));
Ok(())
}