Enforce signatures on user get/set/index functions

This commit is contained in:
J Henry Waugh
2020-09-12 22:28:41 -05:00
parent 0a2f93439e
commit b1f23ac3ed
26 changed files with 553 additions and 21 deletions

View File

@@ -0,0 +1,28 @@
use rhai::plugin::*;
#[derive(Clone)]
pub struct Point {
x: f32,
y: f32,
}
#[export_module]
pub mod test_module {
pub use super::Point;
#[rhai_fn(name = "foo", index_set, index_set)]
pub fn test_fn(input: Point) -> bool {
input.x > input.y
}
}
fn main() {
let n = Point {
x: 0.0,
y: 10.0,
};
if test_module::test_fn(n) {
println!("yes");
} else {
println!("no");
}
}