Skip to content

Conversation

makspll
Copy link
Owner

@makspll makspll commented Jan 25, 2025

Adds support for non-required arguments, with default values passed in during a call:

    #[test]
    fn test_optional_argument_not_required() {
        let fn_ = |a: usize, b: Option<usize>| a + b.unwrap_or(0);
        let script_function = fn_.into_dynamic_script_function();

        with_local_world(|| {
            let out = script_function
                .call(vec![ScriptValue::from(1)], FunctionCallContext::default())
                .unwrap();

            assert_eq!(out, ScriptValue::from(1));
        });
    }

Also bumps rhai version to actual release

@makspll makspll merged commit dbfef74 into staging Jan 25, 2025
14 checks passed
@makspll makspll deleted the feat/optional-arguments branch January 25, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant