We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I register a function that operates on a function pointer
let mut engine = Engine::new(); engine.register_fn("name_of_function", |x: &mut FnPtr| { println!("name of function: {:?}", x.fn_name()); });
fn my_cool_function() { // } my_cool_function.name_of_function()
This successfully prints "my_cool_function". The signature of name_of_function is also correctly (Fn)
I then read about JS Style scriptable event handlers and am inspired to make a map for my function state:
let map = #{ foo: 42 }; fn my_cool_function() { this.foo += 1; // } map.my_cool_function();
This pattern is useful and seems to work for my purposes.
However, doing this does not work.
map.my_cool_function.name_of_function();
I get this error:
called `Result::unwrap()` on an `Err` value: ErrorFunctionNotFound("name_of_function (())", 16:23)
Is this expected behavior?
The text was updated successfully, but these errors were encountered:
Rhai is not JavaScript. Therefore methods are not stored as properties in the hash map.
map.my_cool_function() means my_cool_function(map), in Rust style, not JavaScript style.
map.my_cool_function()
my_cool_function(map)
Therefore, map has no property named my_cool_function.
map
my_cool_function
Sorry, something went wrong.
No branches or pull requests
I register a function that operates on a function pointer
This successfully prints "my_cool_function". The signature of name_of_function is also correctly (Fn)
I then read about JS Style scriptable event handlers and am inspired to make a map for my function state:
This pattern is useful and seems to work for my purposes.
However, doing this does not work.
I get this error:
Is this expected behavior?
The text was updated successfully, but these errors were encountered: