PackageTrack
Sign in Get early access

rhai

Embedded scripting for Rust

1.25.1 10M downloads/mo #3048 most downloaded on crates.io rhaiscript/rhai

What this package is like to depend on

Last release 2 months ago

29 May 2026

Ships fairly regularly

a new release about every 3 months

Most releases are documented

notes for 76 of 94 stable releases

9 versions withdrawn

withdrawn after publishing

10 years old

103 releases · first in 2016

10 releases in the last 12 months

see the full history below

Release timeline

103 releases · Mar 2016 to May 2026
2017 2018 2019 2020 2021 2022 2023 2024 2025 2026
Release Pre-release Withdrawn

Releases

latest 60 of 103
  1. 1.25.1 29 May 2026
    Release notes

    This is a patch release that reverses the change in 1.25.0 that removed certain exports from the rhai::plugin module, which is a breaking change.

    The exports are now re-added will only be removed in the next major version.

    Thanks to @Abendrill #1099.

    Open source →
  2. 1.25.0 24 May 2026
    Release notes

    Bug fixes

    • Engine::compact_script now properly compacts scripts with custom syntax that uses $raw$ (thanks @yuvalrakavy #1079).
    • The string methods split, split_rev and their variants are now marked pure so they can be called on const strings (thanks @theJC #1082).
    • The array method index_of now falls back to value comparison for string argument when no script function of that name is registered (thanks @yinho999 #1086).
    • The walk API now correctly visits the arguments to MethodCall and switch statements (thanks @isSerge #1092 #1093)

    New features

    • A new advanced callback, Engine::on_missing_function, is added (gated under the internals feature) to override default handling when a called function or method is not found (thanks @yuvalrakavy #1067).
    • A new method, EvalContext::new_frame, is added to created an isolated frame guard that automatically restores field values upon Drop (thanks @yuvalrakavy for the idea #1085).
    • \${...} is supported in multi-line literal strings to escape interpolation, yielding literally ${...} for the string (thanks @yinho999 #1089).

    Enhancements

    • Procedural macros such as #[export_module] and #[derive(CustomType)] no longer require importing standard Rhai types (thanks @timokoesters #1071).
    • FnPtr::call_fn_as_method and FnPtr::call_as_method_within_context are added (when not under no_object) to accept a this pointer for calling the function pointer as a method call (thanks @yunfengzh for the request #1080).
    • NativeCallContext::call_method and NativeCallContext::call_native_method are added (when not under no_object) to accept a this pointer for method calls (thanks @yunfengzh for the idea #1080).
    Open source →
    Release notes

    Bug fixes

    • Engine::compact_script now properly compacts scripts with custom syntax that uses $raw$ (thanks @yuvalrakavy #1079).
    • The string methods split, split_rev and their variants are now marked pure so they can be called on const strings (thanks @theJC #1082).
    • The array method index_of now falls back to value comparison for string argument when no script function of that name is registered (thanks @yinho999 #1086).
    • The walk API now correctly visits the arguments to MethodCall and switch statements (thanks @isSerge #1092 #1093)

    New features

    • A new advanced callback, Engine::on_missing_function, is added (gated under the internals feature) to override default handling when a called function or method is not found (thanks @yuvalrakavy #1067).
    • A new method, EvalContext::new_frame, is added to created an isolated frame guard that automatically restores field values upon Drop (thanks @yuvalrakavy for the idea #1085).
    • \${...} is supported in multi-line literal strings to escape interpolation, yielding literally ${...} for the string (thanks @yinho999 #1089).

    Enhancements

    • Procedural macros such as #[export_module] and #[derive(CustomType)] no longer require importing standard Rhai types (thanks @timokoesters #1071).
    • FnPtr::call_fn_as_method and FnPtr::call_as_method_within_context are added (when not under no_object) to accept a this pointer for calling the function pointer as a method call (thanks @yunfengzh for the request #1080).
    • NativeCallContext::call_method and NativeCallContext::call_native_method are added (when not under no_object) to accept a this pointer for method calls (thanks @yunfengzh for the idea #1080).
    • FuncArgs is implemented for SmallVec (thanks @Shatur #1095).
    Open source →
  3. 1.24.0 19 Jan 2026
    Release notes

    This new release has a breaking change because of the upgrade to the getrandom crate to version 0.3.

    As a result, stdweb support has been dropped. It is anticipated that this change would not have significant impact on normal usage.

    Breaking Changes

    • stdweb support is removed. The feature flag stdweb is also removed. Use wasm-bindgen instead.
    • web-time is used for WASM targets instead of instant, which is no longer maintained #1063.

    Bug fixes

    • (Fuzzing) Fixed panic when using sort on an array with a comparer function that does not implement a total order #1058.

    Enhancements

    • The optimizer now optimizes constant object map property accesses (thanks @phsym #1050).
    • Optimization is added to turn if cond1 { if cond2 { ... } } into if cond1 && cond2 { ... }.
    • The method sort for arrays is also aliased to sort_by.
    • The methods sort_desc, order, order_by and order_desc are added to arrays.
    • An exception is now thrown when attempting to use sort on an array containing unsupported element types.

    New features

    • AST::new_from_module is added to create an AST from a shared Module.
    Open source →
    Release notes

    Breaking Changes

    • stdweb support is removed. The feature flag stdweb is also removed. Use wasm-bindgen instead.
    • web-time is used for WASM targets instead of instant, which is no longer maintained #1063.

    Bug fixes

    • (Fuzzing) Fixed panic when using sort on an array with a comparer function that does not implement a total order #1058.

    Enhancements

    • The optimizer now optimizes constant object map property accesses (thanks @phsym #1050).
    • Optimization is added to turn if cond1 { if cond2 { ... } } into if cond1 && cond2 { ... }.
    • The method sort for arrays is also aliased to sort_by.
    • The methods sort_desc, order, order_by and order_desc are added to arrays.
    • An exception is now thrown when attempting to use sort on an array containing unsupported element types.

    New features

    • AST::new_from_module is added to create an AST from a shared Module.
    Open source →
  4. 1.23.6 31 Oct 2025
    Release notes

    Bug fixes

    • The binary bit-wise operators &, | and ^ now work correctly with INT operands (#1037).
    • The methods contains, get, filter and to_json for object maps are now marked pure (#1037).
    • The methods contains, get, parse_le_int, parse_be_int, parse_le_float and parse_be_float for BLOB's are now marked pure (#1037).
    • E can now be used in scientific notation for floating-point and decimal literals (thanks @BrynCooke #1039).
    • The drain and retain methods for object maps no longer empty the target map upon errors (#1043).
    • Using a reserved keyword as a function parameter now returns the VariableExpected parser error (thanks @TheAwiteb #1047).

    Enhancements

    • The method map is added to object maps.
    • The string methods starts_with and ends_with now work with character argument (#1042).
    Open source →
  5. 1.23.5 31 Oct 2025
    Release notes

    This version is the same as version 1.23.6 but maintains compatibility by restricting the ahash dependency to <=0.8.11 because higher versions break no-std builds.

    Open source →
  6. 1.23.4 14 Sep 2025
    Release notes

    Bug fixes

    • (Fuzzing) Fixed crash when using ..= in arrays, BLOB's, bit-fields and iterators (#1004).
    • Modules loaded within a ModuleResolversCollection now properly enable access to the scope etc.
    • Registered functions for comparison operators with only one operand being a custom type now works properly (thanks @mkeeter #1003).
    • NativeCallContext::fn_source now correctly returns the source of the function (usually None). The missing NativeCallContext::call_source is added to return the source of caller (thanks @FlashSystems #1013).
    • Engine::collect_fn_metadata now properly includes functions registered into the global namespace (thanks @therealprof and @matthiasbeyer #1017).

    Enhancements

    • build.rs no longer writes to the source tree but OUT_DIR instead (thanks @matthiasbeyer #1018)
    • CustomType derive macro now supports generic types (thanks @ProphetOSpam #999). The rhai_codegen crate dependency is bumped to 3.0.0 or later.
    • CustomType derive macro now handles Option fields (thanks @agersant #1011).
    • Engine::eval_fn_call is added to make a generic function call.
    • Engine::eval_binary_op is added to quickly compare two Dynamic values.
    • Better handling for 32-bit architectures and enhanced safety by replacing casts with try_from (thanks @therealprof #1009).
    • The new symbol types $token$, $inner$, and $raw$ can now be used in custom syntax definitions (#1023).
    • Engine::register_custom_syntax_without_look_ahead_raw is added to allow the use of $raw$ in custom syntax, which returns the script text character-by-character without processing, by-passing the tokenizer. This in turn allows for parsing arbitrary syntax. (#1022)
    • CallFnOptions::in_all_namespaces is added to allow calling functions in all namespaces, instead of only scripted Rhai functions in the AST.
    Open source →
  7. 1.23.3 14 Sep 2025
    Release notes

    Version Control

    The ahash crate that Rhai depends on has a breaking change since version 0.8.12 which bumps getrandom to version 0.3, braking certain no-std and wasm builds.

    Version 1.23.3: Use this version when building for no-std

    Version 1.23.4: This is the main version for std builds.

    Bug fixes

    • (Fuzzing) Fixed crash when using ..= in arrays, BLOB's, bit-fields and iterators (#1004).
    • Modules loaded within a ModuleResolversCollection now properly enable access to the scope etc.
    • Registered functions for comparison operators with only one operand being a custom type now works properly (thanks @mkeeter #1003).
    • NativeCallContext::fn_source now correctly returns the source of the function (usually None). The missing NativeCallContext::call_source is added to return the source of caller (thanks @FlashSystems #1013).
    • Engine::collect_fn_metadata now properly includes functions registered into the global namespace (thanks @therealprof and @matthiasbeyer #1017).

    Enhancements

    • build.rs no longer writes to the source tree but OUT_DIR instead (thanks @matthiasbeyer #1018)
    • CustomType derive macro now supports generic types (thanks @ProphetOSpam #999). The rhai_codegen crate dependency is bumped to 3.0.0 or later.
    • CustomType derive macro now handles Option fields (thanks @agersant #1011).
    • Engine::eval_fn_call is added to make a generic function call.
    • Engine::eval_binary_op is added to quickly compare two Dynamic values.
    • Better handling for 32-bit architectures and enhanced safety by replacing casts with try_from (thanks @therealprof #1009).
    • The new symbol types $token$, $inner$, and $raw$ can now be used in custom syntax definitions (#1023).
    • Engine::register_custom_syntax_without_look_ahead_raw is added to allow the use of $raw$ in custom syntax, which returns the script text character-by-character without processing, by-passing the tokenizer. This in turn allows for parsing arbitrary syntax. (#1022)
    • CallFnOptions::in_all_namespaces is added to allow calling functions in all namespaces, instead of only scripted Rhai functions in the AST.
    Open source →
    Release notes

    This version is the same as version 1.23.4 but maintains compatibility by restricting the ahash dependency to <=0.8.11 because higher versions break no-std builds.

    Open source →
  8. 1.23.2 14 Sep 2025 withdrawn

    Nothing published for this version

  9. 1.23.1 14 Sep 2025 withdrawn

    Nothing published for this version

  10. 1.23.0 14 Sep 2025 withdrawn

    Nothing published for this version

  11. 1.22.2 03 Jun 2025
    Release notes

    This version removes the version restriction on ahash which may break code for no-std builds.

    Open source →
  12. 1.22.1 03 Jun 2025
    Release notes

    Bug fixes

    • Do not mask out version 0.8.11 for ahash.
    Open source →
  13. 1.22.0 30 May 2025
    Release notes

    Bug fixes

    • (Fuzzing) An integer-overflow bug from an inclusive range in get_bits is fixed (#963).
    • (Fuzzing) Nested functions marked private now properly cause compilation errors (#993).
    • Passing function as a function pointer into a function in an imported module now correctly encapsulates the current environment into the generated function pointer (thanks @dcihlar #976). The same for passing a closure (thanks again, @dcihlar #979).
    • Revised epsilon-based floating-point comparisons (thanks @HactarCE #981).
    • Unneeded optional dependencies are no longer pulled in with features (thanks @HactarCE #987).
    • Engine::collect_fn_metadata now properly includes the namespaces of functions in static modules (thanks @therealprof and @elkowar #992).

    Enhancements

    • Improve display of function call errors by displaying the caller function's source together with line number info (thanks @rhizoome and @HactarCE #988).
    • source and position in NativeCallContext are now fn_source and call_position. A new method call_source is added to return the source (if any) of the caller function (thanks @rhizoome and @HactarCE #989).
    • The &&, || and ?? operators are optimized to allow efficient chaining (#994).
    Open source →
    Release notes

    Bug fixes

    • (Fuzzing) An integer-overflow bug from an inclusive range in get_bits is fixed (#963).
    • (Fuzzing) Nested functions marked private now properly cause compilation errors (#993).
    • Passing function as a function pointer into a function in an imported module now correctly encapsulates the current environment into the generated function pointer (thanks @dcihlar #976). The same for passing a closure (thanks again, @dcihlar #979).
    • Revised epsilon-based floating-point comparisons (thanks @HactarCE #981).
    • Unneeded optional dependencies are no longer pulled in with features (thanks @HactarCE #987).
    • Engine::collect_fn_metadata now properly includes the namespaces of functions in static modules (thanks @therealprof and @elkowar #992).

    Enhancements

    • Improve display of function call errors by displaying the caller function's source together with line number info (thanks @rhizoome and @HactarCE #988).
    • source and position in NativeCallContext are now fn_source and call_position. A new method call_source is added to return the source (if any) of the caller function (thanks @rhizoome and @HactarCE #989).
    • The &&, || and ?? operators are optimized to allow efficient chaining (#994).
    Open source →
  14. 1.21.1 13 Dec 2024 withdrawn

    Nothing published for this version

  15. 1.21.0 25 Jan 2025
    Release notes

    Bug fixes

    • Fixed bug in raw strings (thanks @benatkin 944).
    • get_fn_metadata_list function is marked volatile.
    • no-std plus sync should now build correctly (thanks stargazing-dino 947).

    New Features

    • It is possible to create a function pointer (FnPtr) which binds to a native Rust function or closure via FnPtr::from_dn and FnPtr::from_dyn_fn. When called in script, the embedded function will be called (thanks @makspll 952).

    Enhancements

    • The methods call_fn, call_native_fn, call_fn_raw and call_native_fn_raw are added to EvalContext (thanks @rawhuul 954).
    • A new internals function, Engine::collect_fn_metadata, is added to collect all functions metadata. This is to facilitate better error reporting for missing functions (thanks therealprof 945).
    Open source →
    Release notes

    Bug fixes

    • Fixed bug in raw strings (thanks @benatkin #944).
    • get_fn_metadata_list function is marked volatile.
    • no-std plus sync should now build correctly (thanks stargazing-dino #947).

    New Features

    • It is possible to create a function pointer (FnPtr) which binds to a native Rust function or closure via FnPtr::from_dn and FnPtr::from_dyn_fn. When called in script, the embedded function will be called (thanks @makspll #952).

    Enhancements

    • The methods call_fn, call_native_fn, call_fn_raw and call_native_fn_raw are added to EvalContext (thanks @rawhuul #954).
    • A new internals function, Engine::collect_fn_metadata, is added to collect all functions metadata. This is to facilitate better error reporting for missing functions (thanks therealprof #945).
    Open source →
  16. 1.20.1 13 Dec 2024
    Release notes

    Version 1.20.1

    This is a bug fix release.

    Bug fixes

    • Fixed bug in raw strings with newlines (thanks @benatkin 940).

    Enhancements

    • If a string slice refers to the entire string, the slice is not cloned but returned as-is.
    Open source →
    Release notes

    Bug fixes

    • Fixed bug in raw strings with newlines (thanks @benatkin #940).

    Enhancements

    • If a string slice refers to the entire string, the slice is not cloned but returned as-is.
    Open source →
  17. 1.20.0 02 Nov 2024
    Release notes

    Bug fixes

    • (Fuzzing) An integer-overflow bug from an inclusive range in the bits iterator is fixed.
    • (Fuzzing) An integer-underflow bug from an inclusive range is fixed.
    • Copy strings if the strings interner is busy instead of panicing (thanks @irevoire 917).
    • Deserialization of Scope now works correctly (thanks @AngelicosPhosphoros 918).
    • Support for thumbv6m target is fixed (thanks chxry 919)

    New features

    • Added support for raw strings with the syntax ##..#" ... "#..## (thanks @cellomath 908 910).

    Enhancements

    • New as_immutable_string_ref, as_array_ref, as_blob_ref, as_map_ref plus their _mut variants for Dynamic (thanks @madonuko 904).
    • The break, return and throw statements can now be simply used as switch case statement expressions. Previously it is required that the statement be wrapped in a block.
    Open source →
    Release notes

    Bug fixes

    • (Fuzzing) An integer-overflow bug from an inclusive range in the bits iterator is fixed.
    • (Fuzzing) An integer-underflow bug from an inclusive range is fixed.
    • Copy strings if the strings interner is busy instead of panicing (thanks @irevoire #917).
    • Deserialization of Scope now works correctly (thanks @AngelicosPhosphoros #918).
    • Support for thumbv6m target is fixed (thanks chxry #919)

    New features

    • Added support for raw strings with the syntax ##..#" ... "#..## (thanks @cellomath #908 #910).

    Enhancements

    • New as_immutable_string_ref, as_array_ref, as_blob_ref, as_map_ref plus their _mut variants for Dynamic (thanks @madonuko #904).
    • The break, return and throw statements can now be simply used as switch case statement expressions. Previously it is required that the statement be wrapped in a block.
    Open source →
  18. 1.19.0 30 Jun 2024
    Release notes

    Bug fixes

    • Variable resolver now correctly resolves variables that are captured in a closure.
    • NativeCallContext<'_> (with a lifetime parameter) now parses correctly in the #[export_module] macro. This is to allow for rust_2018_idioms lints (thanks @ltabis 864).
    • The sync feature now works properly in no-std builds (thanks @misssonder 874).
    • More data-race conditions are caught and returned as errors instead of panicking.
    • Missing min and max functions where both operands are floats or Decimal are added.
    • Fixed stack overflow when calling closures recursively (thanks @MageWeiG 880).
    • Engine::call_fn and Engine::call_fn_with_options now correctly use the AST's source field.
    • (Fuzzing) Fixed crash when using ..= in strings.
    • (Fuzzing) A recursive stack-overflow bug in Dynamic::is_hashable is fixed.

    New features

    • The break, continue, return and throw statements can now follow the ?? operator to short-circuit operations where the value is ().
    • A new symbol, $func$, is added to custom syntax to allow parsing of anonymous functions.
    • The filter, drain and retain methods are added to object maps.
    Open source →
    Release notes

    Bug fixes

    • Variable resolver now correctly resolves variables that are captured in a closure.
    • NativeCallContext<'_> (with a lifetime parameter) now parses correctly in the #[export_module] macro. This is to allow for rust_2018_idioms lints (thanks @ltabis #864).
    • The sync feature now works properly in no-std builds (thanks @misssonder #874).
    • More data-race conditions are caught and returned as errors instead of panicking.
    • Missing min and max functions where both operands are floats or Decimal are added.
    • Fixed stack overflow when calling closures recursively (thanks @MageWeiG #880).
    • Engine::call_fn and Engine::call_fn_with_options now correctly use the AST's source field.
    • (Fuzzing) Fixed crash when using ..= in strings.
    • (Fuzzing) A recursive stack-overflow bug in Dynamic::is_hashable is fixed.

    New features

    • The break, continue, return and throw statements can now follow the ?? operator to short-circuit operations where the value is ().
    • A new symbol, $func$, is added to custom syntax to allow parsing of anonymous functions.
    • The filter, drain and retain methods are added to object maps.
    Open source →
  19. 1.18.0 12 Apr 2024
    Release notes

    Starting from this version, we try to put contributors' names on features/enhancements/fixes that they contributed.

    We apologize for neglecting to adopt this practice earlier, but late is better than never!

    Bug fixes

    • The position of an undefined operation call now points to the operator instead of the first operand.
    • The optimize command in rhai-repl now works properly and cycles through None->Simple->Full.
    • Engine::call_fn_XXX no longer return errors unnecessarily wrapped in EvalAltResult::ErrorInFunctionCall.
    • Some tests that panic on 32-bit architecture are fixed (thanks @alexanderkjall #851).
    • The optimizer no longer goes into an infinite loop when optimizing a try statement with an empty body.

    Deprecated API's

    • The plugin macros export_fn, register_exported_fn!, set_exported_fn! and set_exported_global_fn! are deprecated because they do not add value over existing direct API's.

    New features

    • Sub-strings can now be selected from full strings by indexing via ranges, e.g. s[1..4] (thanks @zitsen #845).
    • Doc-comments are now automatically added to function registrations and custom types via the CustomType derive macro (thanks @Itabis #847).
    • New options Engine::set_max_strings_interned and Engine::max_strings_interned are added to limit the maximum number of strings interned in the Engine's string interner.
    • A new advanced callback, Engine::on_invalid_array_index, is added (gated under the internals feature) to handle access to missing properties in object maps.
    • A new advanced callback, Engine::on_missing_map_property, is added (gated under the internals feature) to handle out-of-bound index into arrays.

    Enhancements

    • parse_json is also available without the metadata or serde feature -- it uses Engine::parse_json to parse the JSON text (thanks @Mathieu-Lala #840).
    • FuncRegistration::in_global_namespace and FuncRegistration::in_internal_namespace are added to avoid pulling in FnNamespace.
    • Array/BLOB/string iterators are defined also within the BasicIteratorPackage in addition to the regular array/BLOB/string packages.
    • LexError::Runtime is added for use with Engine::on_parse_token.
    • Shared values under sync are now handled more elegantly -- instead of deadlocking and hanging indefinitely, it spins for a number of tries (waiting one second between each), then errors out.
    Open source →
    Release notes

    Starting from this version, we try to put contributors' names on features/enhancements/fixes that they contributed. We apologize for neglecting to adopt this practice earlier, but late is better than never!

    Bug fixes

    • The position of an undefined operation call now points to the operator instead of the first operand.
    • The optimize command in rhai-repl now works properly and cycles through None->Simple->Full.
    • Engine::call_fn_XXX no longer return errors unnecessarily wrapped in EvalAltResult::ErrorInFunctionCall.
    • Some tests that panic on 32-bit architecture are fixed (thanks @alexanderkjall #851).
    • The optimizer no longer goes into an infinite loop when optimizing a try statement with an empty body.

    Deprecated API's

    • The plugin macros export_fn, register_exported_fn!, set_exported_fn! and set_exported_global_fn! are deprecated because they do not add value over existing direct API's.

    New features

    • Sub-strings can now be selected from full strings by indexing via ranges, e.g. s[1..4] (thanks @zitsen #845).
    • Doc-comments are now automatically added to function registrations and custom types via the CustomType derive macro (thanks @Itabis #847).
    • New options Engine::set_max_strings_interned and Engine::max_strings_interned are added to limit the maximum number of strings interned in the Engine's string interner.
    • A new advanced callback, Engine::on_invalid_array_index, is added (gated under the internals feature) to handle access to missing properties in object maps.
    • A new advanced callback, Engine::on_map_missing_property, is added (gated under the internals feature) to handle out-of-bound index into arrays.

    Enhancements

    • parse_json is also available without the metadata or serde feature -- it uses Engine::parse_json to parse the JSON text (thanks @Mathieu-Lala #840).
    • FuncRegistration::in_global_namespace and FuncRegistration::in_internal_namespace are added to avoid pulling in FnNamespace.
    • Array/BLOB/string iterators are defined also within the BasicIteratorPackage in addition to the regular array/BLOB/string packages.
    • LexError::Runtime is added for use with Engine::on_parse_token.
    • Shared values under sync are now handled more elegantly -- instead of deadlocking and hanging indefinitely, it spins for a number of tries (waiting one second between each), then errors out.
    Open source →
  20. 1.17.1 02 Feb 2024
    Release notes

    This is a bug-fix release that bumps rhai_codegen version to 2.0.0 to satisfy semver rules.

    Open source →
    Release notes

    This is a bug-fix release that bumps rhai_codegen version to 2.0.0 to satisfy semver rules.

    Open source →
  21. 1.17.0 31 Jan 2024 withdrawn
    Release notes

    Starting from this version, the official preferred method of registering an API for a custom type is via the #[derive(CustomType)] macro. The old API is still available for types that reside in external crates (and thus cannot implement CustomType).

    Starting from this version, the new FuncRegistration API is preferred for registering native Rust functions into a Module. The old API is still available but deprecated.

    Starting from this version, fuzzing via Google OSS-Fuzz is used to flush out hidden bugs and edge cases. This should result in higher code quality, better stability and improved security. And indeed, a large number of bugs have been discovered from this and fixed.

    Potentially breaking changes

    • ImmutableString now derefs to &str instead of &SmartString. Normally this should not be a breaking change.
    • Traits implemented by ImmutableString are cleaned up. Normally this should not be a breaking change.
    • EvalContext::new, FloatWrapper and ConditionalExpr are now gated under internals.
    • Previously, Rhai follows Unicode's definition for whitespace, which allows many exotic whitespace characters in scripts. Starting from this version, whitespace follows WhatWG's definition of five ASCII characters (TAB, SPACE, CR, LF and FF), which is the same as Rust. All other Unicode whitespace characters (not inside strings) are not considered whitespace by Rhai. If a script used to contain non-ASCII whitespace characters, it now fails to parse with a syntax error.

    New features

    • Great thanks to @silvergasp for setting up fuzzing.
    • #[derive(CustomType)] is now available, driven by procedural macros in rhai_codegen (thanks @MavethGH #817).
    • A new FuncRegistration API is added to assist in registering native Rust functions into modules with various settings. Some of the original Module::set_fn... API is now deprecated.
    • Functions defined in plugin modules can now be marked as volatile which prevents it from being optimized away even under OptimizationLevel::Full.
    • Added Engine::max_functions and Engine::set_max_functions to limit the maximum number of functions allowed in a script. This is to guard against DOS attacks -- e.g. a simple closure || (two characters) is a function. When max_function is exceeded during script compilation, a new parse error, ParseErrorType::TooManyFunctions, is returned.
    • Engine::get_interned_string is made public instead of gated under internals.

    Deprecated API's

    • rhai::config::hashing::set_ahash_seed, rhai::config::hashing::get_ahash_seed and the RHAI_AHASH_SEED environment variable are deprecated in favor of rhai::config::hashing::set_hashing_seed, rhai::config::hashing::get_hashing_seed and RHAI_HASHING_SEED.
    • AST::clear_doc is deprecated.
    • Much of the Module::update_XXX API is deprecated in favor of using the FuncRegistration API.
    • Module::gen_fn_signatures is deprecated in favor of Module::gen_fn_signatures_with_mapper.

    Fixes to bugs found via fuzzing

    • Fixed crash when parsing multi-segment interpolated string longer than maximum.
    • Fixed crash when parsing unterminated comment.
    • Fixed crash when parsing deeply-nested right-associated operators such as **.
    • Fixed crash when parsing combo-chaining expressions such as (a.b).c.
    • Fixed crash when calling functions that have Dynamic parameters with more than 16 parameters.
    • Fixed crash when indexing into an empty array with negative index.
    • Indexing into an array with a negative index that is larger than the length of the array now throws an out-of-bounds error (similar to positive indices) instead of defaulting to the first element.
    • Fixed edge-case crash in timestamp functions.
    • Fixed crash when indenting a block doc-comment with Unicode multi-byte space characters.
    • Fixed improper parsing of numbers with too many decimal points.
    • Fixed exponential running time when raising a decimal number to a very large power (> 1 million) -- it now returns an overflow error.
    • Shared values that contain reference loops no longer cause a stack overflow when printing.
    • sleep no longer panics on NaN.
    • switch on ranges now work properly.

    Other bug fixes

    • Arrays in object maps now serialize to JSON correctly via to_json() when the serde feature is not enabled.
    • Engine::format_map_as_json now serializes arrays correctly.
    • Engine::gen_fn_signatures(false) now properly skips functions in the standard library.
    • TypeBuilder::with_name now properly sets the display-name of the type for use in generating metadata.

    Enhancements

    • Avoid cloning values unless needed when performing constants propagation in optimization.
    • Added to_int method for characters.
    • Token::FloatConstant and Token::DecimalConstant now carry the original text representation for use in, say, a token mapper.
    • Dynamic::is_fnptr is made a public API.
    • Scope::get_value_ref and Scope::get_value_mut are added.
    • TypeBuilder::with_name now takes any &str instead of just &'static str.
    • Engine::gen_fn_signatures now formats the function signatures using pretty-print names of custom types.
    Open source →
  22. 1.16.3 31 Oct 2023
    Release notes

    Public fields of VarDefInfo are marked deprecated but still accessible.

    Open source →
  23. 1.16.2 24 Sep 2023
    Release notes

    Fixes compilation error when importing multiple modules.

    Open source →
  24. 1.16.1 11 Sep 2023 withdrawn
    Release notes

    Fixes compilation error when using the serde feature with metadata.

    Open source →
  25. 1.16.0 09 Sep 2023 withdrawn
    Release notes

    Compiler version

    The minimum Rust compiler version is raised to 1.66.0.

    Potentially-breaking changes

    • Limit functions (e.g. max_operations, max_array_size etc.) as well as Engine::ensure_data_size_within_limits are no longer exported under unchecked. This should be the correct behavior instead of returning None or zero.
    • The type OptimizationLevel is no longer exported under no_optimize. Originally it was mapped to () under no_optimize.
    • O/S features such as file access and time are no longer disabled when using wasm32-wasi (or any WASM target other than wasm32-unknown).

    Bug fixes

    • Fixes a panic when using this as the first parameter in a namespace-qualified function call.
    • Comparing two different data types (e.g. a custom type and a standard type) now correctly defaults to false (except for != which defaults to true).
    • max and min for integers, strings and characters were missing from the standard library. They are now added.

    Dependencies

    • Minimal version numbers for dependencies are now specified in Cargo.toml to avoid breaking changes in future versions.
    • bitflags is bumped to version 2.
    • syn in rhai_codegen is bumped to version 2.
    • hashbrown (used in no-std builds) is bumped to version 0.14.

    Deprecated API's

    • ParseErrorType::MalformedCallExpr and ParseErrorType::MalformedInExpr are deprecated and will be removed in the next major version.
    • Module::get_custom_type is deprecated in favor of Module::get_custom_type_display_by_name and other new methods.

    New features

    • New exit function that terminates script evaluation regardless of where it is called, even inside deeply-nested function calls.
    • Added Engine::max_variables and Engine::set_max_variables to limit the maximum number of variables allowed within a scope at any time. This is to guard against defining a huge number of variables containing large data just beyond individual data size limits. When max_variables is exceeded a new error, ErrorTooManyVariables, is returned.
    • Added zip function for arrays.
    • Added on_print and on_debug definitions for TypeBuilder.
    • Doc-comments are now included in custom type definitions within plugin modules. They can be accessed via Module::get_custom_type_raw. These doc-comments for custom types are also exported in JSON via Engine::gen_fn_metadata_to_json.

    Enhancements

    • once_cell is used in std environments instead of the home-brew SusLock which is removed.
    • Originally, unit tests use the ? operator liberally to simplify code. However, this causes the loss of proper line numbers when a test fails, making it difficult to identify the exact location of the failure. This is now fixed by changing to unwrap().
    • Many inlined collections are turned back into Vec because they are not transient and do not appear to improve performance. Using Vec seems to be yield better performance as it probably enables more compiler optimizations.
    • General code clean-up to remove optimizations tricks that are not obviously beneficial in favor of clearer code.
    Open source →
  26. 1.15.1 26 Jun 2023
    Release notes

    Bug fixes

    • Dynamic::deep_scan is fixed so now it properly scans arrays, object maps and function pointers embedded inside data.
    Open source →
  27. 1.15.0 18 Jun 2023
    Release notes

    Bug fixes

    • Fixes a concurrency error in static hashing keys (thanks garypen!).

    Enhancements

    • Expressions involving this should now run slightly faster due to a dedicated AST node ThisPtr.
    • A take function is added to the standard library to take ownership of any data (replacing with ()) in order to avoid cloning.
    • Dynamic::take is added to take ownership of the data (replacing with ()) in order to avoid cloning.
    • EvalAltResult::ErrorMismatchOutputType now gives a better name for the requested generic type (e.g. &str is now &str and not string).
    Open source →
  28. 1.14.0 02 May 2023
    Release notes

    This new version contains a substantial number of bug fixes for edge cases.

    A new syntax is supported to facilitate writing object methods in script.

    The code hacks that attempt to optimize branch prediction performance are removed because benchmarks do not show any material speed improvements.

    Bug fixes

    • is_shared is a reserved keyword and is now handled properly (e.g. it cannot be the target of a function pointer).
    • Re-optimizing an AST via optimize_ast with constants now works correctly for closures. Previously the hidden Share nodes are not removed and causes variable-not-found errors during runtime if the constants are not available in the scope.
    • Expressions such as (v[0].func()).prop now parse correctly.
    • Shadowed variable exports are now handled correctly.
    • Shadowed constant definitions are now optimized correctly when propagated (e.g. const X = 1; const X = 1 + 1 + 1; X now evaluates to 3 instead of 0).
    • Identifiers and comma's in the middle of custom syntax now register correctly.
    • Exporting an object map from a module with closures defined on properties now works correctly when those properties are called to mimic method calls in OOP-style.
    • Compiling for thumbv6m-none-eabi target (e.g. Raspberry Pi Pico) now completes successfully. Dependency to no-std-compat is now pointed to the latest repo instead of crates.io.

    New features

    • It is now possible to require a specific type to the this pointer for a particular script-defined function so that it is called only when the this pointer contains the specified type.
    • is_def_fn is extended to support checking for typed methods, with syntax is_def_fn(this_type, fn_name, arity)
    • Dynamic::take is added as a short-cut for std::mem::take(&mut value).

    Enhancements

    • Engine::is_symbol_disabled is added to test whether a particular keyword/symbol is disabled.
    • Support is added to deserialize a Dynamic value containing custom types or shared values back into another Dynamic (essentially a straight cloned copy).
    Open source →
  29. 1.13.0 16 Mar 2023
    Release notes

    This version attempts a number of optimizations that may yield small speed improvements:

    • Simple operators (e.g. integer arithmetic) are inlined to avoid the overhead of a function call.
    • The tokenizer uses pre-calculated tables (generated by GNU gperf) for keyword recognition.
    • A black-arts trick (see Engine::black_box) is used to prevent LLVM from optimizing hand-tuned AST node matches back into a lookup table, which messes up branch prediction on modern CPU's.

    Bug fixes

    • Complex indexing/dotting chains now parse correctly, for example: a[b][c[d]].e
    • map and filter for arrays are marked pure. Warnings are added to the documentation of pure array methods that take this closures.
    • Syntax such as foo.bar::baz no longer panics, but returns a proper parse error.
    • Expressions such as !inside now parses correctly instead of as !in followed by side.
    • Custom syntax starting with symbols now works correctly and no longer raises a parse error.
    • Comparing different custom types now works correctly when the appropriate comparison operators are registered.
    • Some op-assignments, such as x += y where x and y are char, now work correctly instead of failing silently.
    • Op-assignments to bit flags or bit ranges now work correctly.

    Potentially breaking changes

    • The trait method ModuleResolver::resolve_raw (which is a low-level API) now takes a &mut Scope parameter. This is a breaking change because the signature is modified, but this trait method has a default and is rarely called/implemented in practice.
    • Module::eval_ast_as_new_raw (a low-level API) now takes a &mut Scope instead of the Scope parameter. This is a breaking change because the &mut is now required.
    • Engine::allow_loop_expressions now correctly defaults to true (was erroneously false by default).

    Enhancements

    • Engine::new_raw is now const and runs very fast, delaying all other initialization until first use.
    • The functions min and max are added for numbers.
    • Range cases in switch statements now also match floating-point and decimal values. In order to support this, however, small numeric ranges cases are no longer unrolled.
    • Loading a module via import now gives the module access to the current scope, including variables and constants defined inside.
    • Some very simple operator calls (e.g. integer add) are inlined to avoid the overhead of a function call, resulting in a small speed improvement.
    • The tokenizer now uses table-driven keyword recognizers generated by GNU gperf. At least theoretically it should be faster...
    • The field isAnonymous is added to JSON functions metadata.
    Open source →
  30. 1.12.0 31 Dec 2022
    Release notes

    Bug fixes

    • Integer numbers that are too large to deserialize into INT now fall back to Decimal or FLOAT instead of silently truncating.
    • Parsing deeply-nested closures (e.g. ||{||{||{||{||{||{||{...}}}}}}}) no longer panics but will be confined to the nesting limit.
    • Closures containing a single expression are now allowed in Engine::eval_expression etc.
    • Strings interpolation now works under Engine::new_raw without any standard package.
    • Fn now throws an error if the name is a reserved keyword as it cannot possibly map to such a function. This also disallows creating function pointers to custom operators which are defined as disabled keywords (a mouthful), but such custom operators are designed primarily to be used as operators.

    Breaking API changes

    • The callback for initializing a debugger instance has changed to Fn(&Engine, Debugger) -> Debugger. This allows more control over the initial setup of the debugger.
    • The internal macro reify! is no longer available publicly.

    Deprecated API's

    • Module::with_capacity is deprecated.
    • The internal method Engine::eval_statements_raw is deprecated.
    • Array overloaded methods that take function names (as string) are deprecated in favor of using the Fn("...") call.

    Speed improvements

    • The function registration mechanism is revamped to take advantage of constant generics, among others, to omit checking code where possible. This yields a 10-20% speed improvements on certain real-life, function-call-heavy workloads.
    • Functions taking function pointers as parameters, usually called with closures, now run faster because a link to the anonymous function (generated by the closure) is stored together with the function pointer itself. This allows short-circuiting the function lookup step.

    Net features

    First class functions (sort of)

    • A function pointer created via a closure definition now links to the particular anonymous function itself.
    • This avoids a potentially expensive function lookup when the function pointer is called, speeding up closures.
    • Closures now also encapsulate their defining environment, so function pointers can now be freely exported from modules!

    !in

    • A new operator !in is added which maps to !(... in ...).

    Engine::call_fn_with_options

    • Engine::call_fn_raw is deprecated in favor of Engine::call_fn_with_options which allows setting options for the function call.
    • The options are for future-proofing the API.
    • In this version, it gains the ability to set the value of the custom state (accessible via NativeCallContext::tag) for a function evaluation, overriding Engine::set_default_tag.

    Compact a script for compression

    • Engine::compact_script is added which takes a valid script (it still returns parsing errors) and returns a compacted version of the script with all insignificant whitespaces and all comments removed.
    • A compact script compresses better than one with liberal whitespaces and comments.
    • Unlike some uglifiers or minifiers, Engine::compact_script does not optimize the script in any way, nor does it rename variables.

    Enhanced array API

    • Array methods that take a function pointer, usually a closure (e.g. map, filter, index_of, reduce etc.), can now bind the array element to this when calling a closure.
    • This vastly improves performance when working with arrays of large types (e.g. object maps) by avoiding unnecessary cloning.
    • find and find_map are added for arrays.
    • for_each is also added for arrays, allowing a closure to mutate array elements (bound to this) in turn.

    Enhancements

    • Optimizations have been done to key data structures to minimize size and creation time, which involves turning rarely-used fields into Option<Box<T>>. This resulted in some speed improvements.
    • CallableFunction is exported under internals.
    • The TypeBuilder type and CustomType trait are no longer marked as volatile.
    • FuncArgs is also implemented for arrays.
    • Engine::set_XXX API can now be chained.
    • EvalContext::scope_mut now returns &mut Scope instead of &mut &mut Scope.
    • Line-style doc-comments are now merged into a single string to avoid creating many strings. Block-style doc-comments continue to be independent strings.
    • Block-style doc-comments are now "un-indented" for better formatting.
    • Doc-comments on plugin modules are now captured in the module's doc field.
    • Expression nesting levels is refined such that it grows less excessively for common patterns.
    • The traits Index and IndexMut are added to FnPtr.
    • FnPtr::iter_curry and FnPtr::iter_curry_mut are added.
    • Dynamic::deep_scan is added to recursively scan for Dynamic values.
    • >> and << operators on integers no longer throw errors when the number of bits to shift is out of bounds. Shifting by a negative number of bits simply reverses the shift direction.
    Open source →
  31. 1.11.0 11 Nov 2022
    Release notes

    Speed improvements

    • Due to a code refactor, built-in operators for standard types now run even faster, in certain cases by 20-30%.

    Bug fixes

    • Engine::parse_json now returns an error on unquoted keys to be consistent with JSON specifications.
    • import statements inside eval no longer cause errors in subsequent code.
    • Functions marked global in imported modules with no alias names now work properly.
    • Incorrect loop optimizations that are too aggressive (e.g. unrolling a do { ... } until true with a break statement inside) and cause crashes are removed.
    • Dynamic::is now works properly for shared values.

    Breaking changes

    • NativeCallContext::new is completely deprecated and unimplemented (always panics) in favor of new API's.

    New features

    Dynamic detection API

    • New methods are added to Dynamic in the form of is_XXX() where XXX is a type (e.g. is_int, is_unit, is_bool, is_array).
    • This new API is to make it easier to detect the data type, instead of having to call is::<XXX>().

    Loop expressions

    • Loops (such as loop, do, while and for) can now act as expressions, with the break statement returning an optional value.
    • Normal loops return () as the value.
    • Loop expressions can be enabled/disabled via Engine::set_allow_loop_expressions

    Static hashing

    • It is now possible to specify a fixed seed for use with the ahash hasher, via a static function rhai::config::hashing::set_ahash_seed or an environment variable (RHAI_AHASH_SEED), in order to force static (i.e. deterministic) hashes for function signatures.
    • This is necessary when using Rhai across shared-library boundaries.
    • A build script is used to extract the environment variable (RHAI_AHASH_SEED, if any) and splice it into the source code before compilation.

    no_time for no timestamps

    • A new feature, no_time, is added to disable support for timestamps.
    • This may be necessary when building for architectures without time support, such as raw WASM.

    Serializable Scope

    • Scope is now serializable and deserializable via serde.

    Store and recreate NativeCallContext

    • A convenient API is added to store a NativeCallContext into a new NativeCallContextStore type.
    • This allows a NativeCallContext to be stored and recreated later on.

    Call native Rust functions in NativeCallContext

    • NativeCallContext::call_native_fn is added to call registered native Rust functions only.
    • NativeCallContext::call_native_fn_raw is added as the advanced version.
    • This is often desirable as Rust functions typically do not want a similar-named scripted function to hijack the process -- which will cause brittleness.

    Custom syntax improvements

    • The look-ahead symbol for custom syntax now renders a string literal in quotes (instead of the generic term string).
    • This facilitates more accurate parsing by separating strings and identifiers.

    Limits API

    • Methods returning maximum limits (e.g. Engine::max_string_len) are now available even under unchecked.
    • This helps avoid the proliferation of unnecessary feature flags in third-party library code.

    Enhancements

    • parse_json function is added to parse a JSON string into an object map.
    • Error::ErrorNonPureMethodCallOnConstant is added which is raised when a non-pure method is called on a constant value.
    Open source →
  32. 1.10.1 22 Sep 2022
    Release notes

    Bug fixes

    • Compiling on 32-bit architectures no longer cause a compilation error.
    • Fix type-size test for 32-bit architectures without the decimal feature.

    Custom syntax with state

    • [Engine::register_custom_syntax_with_state_raw] is added. The custom syntax parser and implementation functions take on an additional parameter that holds a user-defined custom state which should substantially simplify writing some custom parsers.
    • [Engine::register_custom_syntax_raw] is deprecated.
    Open source →
  33. 1.10.0 10 Sep 2022
    Release notes

    This version introduces Fast Operators mode, which is turned on by default but can be disabled via a new options API: Engine::set_fast_operators.

    Fast Operators mode assumes that none of Rhai's built-in operators for standard data types are overloaded by user-registered functions. In the vast majority of cases this should be so (really, who overloads the + operator for integers anyway?).

    This assumption allows the Engine to avoid checking for overloads for every single operator call. This usually results in substantial speed improvements, especially for expressions.

    Minimum Rust Version

    The minimum Rust version is now 1.61.0 in order to use some const generics.

    Bug fixes

    • API for registering property getters/setters and indexers to an Engine now works with functions that take a first parameter of NativeCallContext.
    • Missing API function Module::set_getter_setter_fn is added.
    • To avoid subtle errors, simple optimization is used for rhai-run; previous it was full optimization.

    Deprecated API

    • All versions of the Engine::register_XXX_result API that register a function returning Result<T, Box<EvalAltResult>> are now deprecated. The regular, non-result versions handle all functions correctly.

    New features

    Fast operators

    • A new option Engine::fast_operators is introduced (default to true) to enable/disable Fast Operators mode.

    Fallible type iterators

    • For very special needs, the ability to register fallible type iterators is added.

    Expressions

    • if-expressions are allowed in Engine::eval_expression and Engine::compile_expression provided that both statement blocks each contain at most a single expression.
    • switch-expressions are allowed in Engine::eval_expression and Engine::compile_expression provided that match actions are expressions only.

    Enhancements

    • is_empty method is added to arrays, BLOB's, object maps, strings and ranges.
    • StaticModuleResolver now stores the path in the module's id field.
    • Engine::module_resolver is added to grant access to the Engine's module resolver.
    • Constants and variables now have types in generated definition files.
    Open source →
  34. 1.9.1 29 Aug 2022
    Release notes

    This is a bug-fix version that fixes a bug.

    Accessing properties in Strict Variables Mode no longer generates a variable not found error.

    Open source →
  35. 1.9.0 21 Aug 2022
    Release notes

    The minimum Rust version is now 1.60.0 in order to use the dep: syntax for dependencies.

    Bug fixes

    • switch cases with conditions that evaluate to constant () no longer optimize to false (should raise a type error during runtime).
    • Fixes concatenation of BLOB's and strings, where the BLOB's should be interpreted as UTF-8 encoded strings.
    • Capturing an unknown variable in a closure no longer panics.
    • Fixes panic in interpolated strings with constant expressions.
    • Using call_fn_raw on a function without evaluating the AST no longer panics on namespace-qualified function calls due to import statements not run.
    • Some reserved tokens (such as "?", "++") cannot be used in custom syntax; this is now fixed.

    Breaking changes

    • The first closure passed to Engine::register_debugger now takes a single parameter which is a reference to the current Engine.

    New features

    New feature flags

    • A new feature flag, std, which is enabled by default, is added due to requirements from dependency crates.
    • A new feature flag, no_custom_syntax, is added to remove custom syntax support from Rhai for applications that do not require it (which should be most).

    Module documentation

    • Comment lines beginning with //! (requires the metadata feature) are now collected as the script file's module documentation.
    • AST and Module have methods to access and manipulate documentation.

    Output definition files

    • An API is added to automatically generate definition files from a fully-configured Engine, for use with the Rhai Language Server.

    Short-hand to function pointers

    • Using a script-defined function's name (in place of a variable) implicitly creates a function pointer to the function.

    Top-level functions

    • Crate-level functions rhai::eval, rhai::run, rhai::eval_file, rhai::run_file are added as convenient wrappers.

    CustomType trait and TypeBuilder

    • A new volatile API, Engine::build_type, enables registration of the entire API of a custom type in one go, provided that the custom type implements the CustomType trait (which uses TypeBuilder to register the API functions).

    Simpler Package API

    • It is now easier to register packages via the Package::register_into_engine and Package::register_into_engine_as API.
    • Defining a custom package with base packages is also much easier with a new syntax - put the new base packages after a colon.

    Enhancements

    switch statement

    • switch cases can now include multiple values separated by |.
    • Duplicated switch cases are now allowed.
    • The error ParseErrorType::DuplicatedSwitchCase is deprecated.
    • Ranges in switch statements that are small (currently no more than 16 items) are unrolled if possible.

    Others

    • EvalContext::eval_expression_tree_raw and Expression::eval_with_context_raw are added to allow for not rewinding the Scope at the end of a statements block.
    • A new range function variant that takes an exclusive range with a step.
    • as_string is added to BLOB's to convert it into a string by interpreting it as a UTF-8 byte stream.
    • FnAccess::is_private, FnAccess::is_public, FnNamespace::is_module_namespace and FnNameSpace::is_global_namespace are added for convenience.
    • Iterator<Item=T> type for functions metadata is simplified to Iterator<T>.
    • Scope::remove is added to remove a variable from a Scope, returning its value.
    • The code base is cleaner by running it through Clippy.
    • ParseError::err_type and ParseError::position are added for convenience.
    • The source of an AST compiled from a script file is set to the file's path.
    • |> and <| are now reserved symbols.
    Open source →
  36. 1.8.0 01 Jul 2022
    Release notes

    Bug fixes

    • Self-contained AST now works properly with Engine::call_fn.
    • Missing to_int from Decimal is added.
    • Parsing of index expressions is relaxed and many cases no longer result in an index-type error to allow for custom indexers.
    • Merging or combining a self-contained AST into another AST now works properly.
    • Plugin modules/functions no longer generate errors under #![deny(missing_docs)].
    • Calling a property on a function call that returns a shared value no longer causes an error.
    • Strict Variables Mode now checks for module namespaces within functions as well.
    • Module defined via Engine::register_static_module are now checked in Strict Variables Mode.

    Reserved Symbols

    • ?, ??, ?., ?[ and !. are now reserved symbols.

    Deprecated API's

    • FnPtr::num_curried is deprecated in favor of FnPtr::curry().len().

    New features

    • The Elvis operators (?. and ?[) are now supported for property access, method calls and indexing.
    • The null-coalescing operator (??) is now supported to short-circuit () values.

    Enhancements

    • Indexing and property access are now faster.
    • EvalAltResult::IndexNotFound is added to aid in raising errors for indexers.
    • Engine::def_tag, Engine::def_tag_mut and Engine::set_tag are added to manage a default value for the custom evaluation state, accessible via EvalState::tag() (which is the same as NativeCallContext::tag()).
    • Originally, the debugger's custom state uses the same state as EvalState::tag() (which is the same as NativeCallContext::tag()). It is now split into its own variable accessible under Debugger::state().
    • Non-borrowed string keys can now be deserialized for object maps via serde.
    • Scope::get is added to get a reference to a variable's value.
    • Variable resolvers can now return a shared value which can be mutated.
    Open source →
  37. 1.7.0 04 May 2022
    Release notes

    Bug fixes

    • Compound assignments now work properly with indexers.
    • Cloning a Scope no longer turns all constants to mutable.

    Script-breaking changes

    • Strict Variables Mode no longer returns an error when an undeclared variable matches a variable/constant in the provided external Scope.

    Potentially breaking API changes

    • The Engine::on_var and Engine::on_parse_token API's are now marked unstable/volatile.
    • The closures passed to Engine::on_var, Engine::on_def_var and Engine::register_debugger take EvalContext instead of &EvalContext or &mut EvalContext.
    • The following enum's are marked non_exhaustive: AccessMode, FnAccess, FnNamespace, FnMetadata, OptimizationLevel

    New API

    • Module::eval_ast_as_new_raw is made public as a low-level API.
    • format_map_as_json is provided globally, which is the same as to_json for object maps.
    • Engine::call_fn_raw_raw is added to add speed to repeated function calls.
    • Engine::eval_statements_raw is added to evaluate a sequence of statements.

    New features

    • A custom state is provided that is persistent during the entire evaluation run. This custom state is a Dynamic, which can hold any data, and can be accessed by the host via EvalContext::tag, EvalContext::tag_mut, NativeCallContext::tag and GlobalRuntimeState.tag.

    Enhancements

    • Improper switch case condition syntax is now caught at parse time.
    • Engine::parse_json now natively handles nested JSON inputs (using a token remap filter) without needing to replace { with #{.
    • to_json is added to object maps to cheaply convert it to JSON format (() is mapped to null, all other data types must be supported by JSON)
    • FileModuleResolver now accepts a custom Scope to provide constants for optimization.
    • New variants, Start and End, are added to DebuggerEvent triggered at the start/end of script evaluation.
    Open source →
  38. 1.6.1 11 Apr 2022
    Release notes

    Bug fixes

    • Functions with Dynamic parameters now work in qualified calls from imported modules.
    • rhai-repl now compiles with the new patch version of rustyline.
    • rhai_codegen dependency is now explicitly 1.4 or higher.

    Script-breaking changes

    • split now splits a string by whitespaces instead of splitting it into individual characters. This is more in line with common practices.
    • A new function to_chars for strings is added to split the string into individual characters.

    Enhancements

    • Strings are now directly iterable (via for .. in) yielding individual characters.
    Open source →
  39. 1.6.0 30 Mar 2022
    Release notes

    This version, in particular, fixes a plugin macro hygiene error for the nightly compiler:

    error[E0425]: cannot find value `args` in this scope
    

    Compiler version

    • Minimum compiler version is now 1.57 due to smartstring dependency.

    Bug fixes

    • Fixed macro hygiene error with nightly compiler.
    • Invalid property or method access such as a.b::c.d or a.b::func() no longer panics but properly returns a syntax error.
    • Scope::is_constant now returns the correct value.
    • Exporting a variable that contains a local function pointer (including anonymous function or closure) now raises a runtime error.
    • Full optimization is now skipped for method calls.

    New features

    • Type aliases in plugin modules are now used as friendly names for custom types. This makes plugin modules more self-contained when they are used to define a custom type's API.

    Enhancements

    • Variable definitions are optimized so that shadowed variables are reused as much as possible to reduce memory consumption.
    • FnAccess and FnNamespace now implement Ord and PartialOrd.
    • The event_handler_map example is enhanced to prevent shadowing of the state object map.
    • Separation of constants in function calls is removed as its performance benefit is dubious.
    • A function sleep is added to block the current thread by a specified number of seconds.
    • Scope::set_alias is added to export a variable under a particular alias name.
    • starts_with and ends_with are added for strings.
    • Variables in modules registered via register_global_module can now be accessed in the global namespace.
    • Dynamic::into_read_only is added to convert a Dynamic value into constant.
    • Module now holds a collection of custom types with an API.
    Open source →
  40. 1.5.0 15 Feb 2022
    Release notes

    This version adds a debugging interface, which can be used to integrate a debugger.

    Based on popular demand, an option is added to throw exceptions when invalid properties are accessed on object maps (default is to return ()).

    Also based on popular demand, the REPL tool now uses a slightly-enhanced version of rustyline for line editing and history.

    Bug fixes

    • In Scope::clone_visible, constants are now properly cloned as constants.
    • Variables introduced inside try blocks are now properly cleaned up upon an exception.
    • Off-by-one error in character positions after a comment line is now fixed.
    • Globally-defined constants are now encapsulated correctly inside a loaded module and no longer spill across call boundaries.
    • Type names display is fixed.
    • Exceptions thrown inside function calls now unwrap correctly when catch-ed.
    • Error messages for certain invalid property accesses are fixed.

    Script-breaking changes

    • For consistency with the import statement, the export statement no longer exports multiple variables.
    • Appending a BLOB to a string (via +, +=, append or string interpolation) now treats the BLOB as a UTF-8 encoded string.
    • Appending a string/character to a BLOB (via += or append) now adds the string/character as a UTF-8 encoded byte stream.

    New features

    • A debugging interface is added.
    • A new bin tool, rhai-dbg (aka The Rhai Debugger), is added to showcase the debugging interface.
    • A new package, DebuggingPackage, is added which contains the back_trace function to get the current call stack anywhere in a script.
    • Engine::set_fail_on_invalid_map_property is added to control whether to raise an error (new EvalAltResult::ErrorPropertyNotFound) when invalid properties are accessed on object maps.
    • Engine::set_allow_shadowing is added to allow/disallow variables shadowing, with new errors EvalAltResult::ErrorVariableExists and ParseErrorType::VariableExists.
    • Engine::on_def_var allows registering a closure which can decide whether a variable definition is allow to continue, during compilation or runtime, or should fail with an error (ParseErrorType::ForbiddenVariable or EvalAltResult::ErrorForbiddenVariable).
    • A new syntax for defining custom packages is introduced that removes the need to specify the Rhai crate name (internally uses the $crate meta variable).

    Enhancements

    • Default features for dependencies (such as ahash/std and num-traits/std) are no longer required.
    • The no_module feature now eliminates large sections of code via feature gates.
    • Debug display of AST is improved.
    • NativeCallContext::call_level() is added to give the current nesting level of function calls.
    • A new feature, bin-features, pulls in all the required features for bin tools.
    • AST position display is improved:
      • Expr::start_position is added to give the beginning of the expression (not the operator's position).
      • StmtBlock and Stmt::Block now keep the position of the closing } as well.
    • EvalAltResult::unwrap_inner is added to access the base error inside multiple layers of wrappings (e.g. EvalAltResult::ErrorInFunction).
    • Yet another new syntax is introduced for def_package! that further simplifies the old syntax.
    • A new method to_blob is added to convert a string into a BLOB as UTF-8 encoded bytes.
    • A new method to_array is added to convert a BLOB into array of integers.

    REPL tool changes

    The REPL bin tool, rhai-rpl, has been enhanced.

    Build changes

    • The rustyline feature is now required in order to build rhai-repl.
    • Therefore, rhai-repl is no longer automatically built when using a simple cargo build with default features.

    Line editor

    • rhai-repl now uses a modified version of rustyline as a line editor with history.
    • Ctrl-Enter can now be used to enter multiple lines without having to attach the \ continuation character the end of each line.
    • Bracketed paste is supported, even on Windows (version 10 or above), so pasting code directly into rhai-repl is made much more convenient.

    New commands

    • strict to turn on/off Strict Variables Mode.
    • optimize to turn on/off script optimization.
    • history to print lines history.
    • !!, !num, !text and !?text to recall a history line.
    • keys to print all key bindings.
    Open source →
  41. 1.4.1 23 Jan 2022
    Release notes

    This is primarily a bug-fix version which fixes a large number of bugs.

    Bug fixes

    • Expressions such as x = x + 1 no longer panics.
    • Padding arrays with another array via pad no longer loops indefinitely.
    • chop for arrays and BLOB's now works properly.
    • set_bit for bit-flags with negative index now works correctly.
    • Misnamed params field name in the JSON output of Engine::gen_fn_metadata_to_json is fixed (was incorrectly named type).
    • Fixes a potential unsafe violation in for loop.
    • Missing to_hex, to_octal and to_binary for i128 and u128 are added.
    • remove for arrays and BLOB's now treat negative index correctly.
    • parse_int now works properly for negative numbers.
    • Engine::gen_fn_signatures now generates signatures for external packages registered via Engine::register_global_module.
    • \r\n pairs are now recognized correctly for doc-comments.

    Enhancements

    • Formatting of return types in functions metadata info is improved.
    • Use SmartString for Scope variable names and remove unsafe lifetime casting.
    • Functions in the standard library now have doc-comments (which can be obtained via Engine::gen_fn_metadata_to_json).
    • get and set methods are added to arrays, BLOB's, object maps and strings.
    Open source →
  42. 1.4.0 11 Jan 2022
    Release notes

    This version adds support for integer ranges via the .. and ..= operators. Many standard API's are extended with range parameters where appropriate.

    Script-breaking changes

    • is is (pun intended) now a reserved keyword to prepare for possible future type checking expressions (e.g. x is "string").

    Breaking changes

    • LogicPackage is removed from CorePackage.
    • Bit-field functions are moved into a new BitFieldPackage (used to be in LogicPackage) which makes more sense.

    Bug fixes

    • Custom syntax now works properly inside binary expressions and with method calls.
    • Hex numbers with the high-bit set now parse correctly into negative integer numbers.
    • Constructing a literal array or object map now checks for size limits for each item instead of at the very end when it is already too late.
    • Non-INT integer types are now treated exactly as custom types under only_i64 and only_i32.
    • Calling pad on an array now checks for total size over limit after each item added.

    New features

    • Added support for integer ranges via the .. and ..= operators.
    • Added EvalAltResult::ErrorCustomSyntax to catch errors in custom syntax, which should not happen unless an AST is compiled on one Engine but evaluated on another unrelated Engine.

    Enhancements

    • BLOB's are refined to display in a more compact hex format.
    • A new syntax is introduced for def_package! that will replace the old syntax in future versions.
    • Added NativeCallContext::call_fn to easily call a function.
    • Doc-comments on plugin module functions are extracted into the functions' metadata.

    Deprecated API's

    • Expression::get_variable_name is deprecated in favor of the new Expression::get_string_value.
    • The old syntax of def_package! is deprecated in favor of the new syntax.
    Open source →
  43. 1.3.0 12 Dec 2021
    Release notes

    This version adds native support for BLOB's (byte arrays), as well as a number of configuration settings to fine-tun language features.

    Compiler requirement

    • Minimum compiler version is now 1.51.

    Bug fixes

    • from_dynamic now supports deserializing Option.

    New features

    • BLOB (essentially a byte array) is added as a supported primitive value type parallel to arrays.
    • New options for Engine which allows disabling if-expressions, switch-expressions, statement expressions, anonymous functions and/or looping (i.e. while, loop, do and for statements):
      • Engine::set_allow_if_expression
      • Engine::set_allow_switch_expression
      • Engine::set_allow_statement_expression
      • Engine::set_allow_anonymous_fn
      • Engine::set_allow_looping
    • New strict variables mode for Engine (enabled via Engine::set_strict_variables) to throw parse errors on undefined variable usage. Two new parse error variants, ParseErrorType::VariableNotFound and ParseErrorType::ModuleNotFound, are added.

    Enhancements

    • Two double quotes ("") in a string literal now maps to "; two back-ticks (``) in a literal string now maps to `.
    • Added Engine::register_type_with_name_raw to register a custom type based on a fully-qualified type path.
    • Added into_array and into_typed_array for Dynamic.
    • Added FnPtr::call and FnPtr::call_within_context to simplify calling a function pointer.
    • A function's hashes are included in its JSON metadata to assist in debugging. Each function's baseHash field in the JSON object should map directly to the pre-calculated hash in the function call.
    • Expression now derefs to Expr.

    Deprecated and Gated API's

    • NativeCallContext::new is deprecated because it is simpler to call a function pointer via FnPtr::call.
    • AST::merge_filtered and AST::combine_filtered are no longer exported under no_function.
    • AST::new and AST::new_with_source are moved under internals.
    • FnPtr::call_dynamic is deprecated in favor of FnPtr::call_raw.
    Open source →
  44. 1.2.1 24 Nov 2021
    Release notes

    Bug fixes

    • Array methods (such as map) taking a closure with captures as argument now works properly.
    Open source →
  45. 1.2.0 19 Nov 2021
    Release notes

    Bug fixes (potentially script-breaking)

    • As originally intended, function calls with a bang (!) now operates directly on the caller's scope, allowing variables inside the scope to be mutated.
    • As originally intended, Engine::XXX_with_scope API's now properly propagate constants within the provided scope also to functions in the script.
    • Printing of integral floating-point numbers is fixed (used to only prints 0.0).
    • func!() calls now work properly under no_closure.
    • Fixed parsing of unary negation such that expressions like if foo { ... } -x parses correctly.

    New features

    • #[cfg(...)] attributes can now be put directly on plugin functions or function defined in a plugin module.
    • A custom syntax parser can now return a symbol starting with $$ to inform the implementation function which syntax variant was actually parsed.
    • AST::iter_literal_variables is added to extract all top-level literal constant/variable definitions from a script without running it.
    • Engine::call_fn_dynamic is deprecated and Engine::call_fn_raw is added which allows keeping new variables in the custom scope.

    Enhancements

    • Array methods now avoid cloning as much as possible (although most predicates will involve cloning anyway if passed a closure).
    • Array methods that take function pointers (e.g. closures) now optionally take the function name as a string.
    • Array adds the dedup method.
    • Array adds a sort method with no parameters which sorts homogeneous arrays of built-in comparable types (e.g. INT).
    • Inlining is disabled for error-path functions because errors are exceptional and scripts usually fail completely when an error is encountered.
    • The optimize module is completely eliminated under no_optimize, which should yield smaller code size.
    • NativeCallContext::position is added to return the position of the function call.
    • Scope::clone_visible is added that copies only the last instance of each variable, omitting all shadowed variables.

    Deprecated API's

    • NativeCallContext::call_fn_dynamic_raw is deprecated and NativeCallContext::call_fn_raw is added.
    • From<EvalAltResult> for Result<T, Box<EvalAltResult> > is deprecated so it will no longer be possible to do EvalAltResult::ErrorXXXXX.into() to convert to a Result; instead, Err(EvalAltResult:ErrorXXXXX.into()) must be used. Code is clearer if errors are explicitly wrapped in Err.
    Open source →
  46. 1.1.2 05 Nov 2021
    Release notes

    Bug fixes

    • 0.0 now prints correctly (used to print 0e0).
    • Unary operators are now properly recognized as an expression statement.
    • Reverses a regression on string + operations.
    • The global namespace is now searched before packages, which is the correct behavior.
    Open source →
  47. 1.1.1 01 Nov 2021
    Release notes

    Bug fixes

    • Assignment to indexing expression with dot expressions inside no longer cause a compilation error.
    • The no_module and internals features now work together without a compilation error.
    • String literal operations (such as "hello" + ", world") now optimizes correctly.
    Open source →
  48. 1.1.0 11 Oct 2021
    Release notes

    Bug fixes

    • Custom syntax starting with a disabled standard keyword now works properly.
    • When calling Engine::call_fn, new variables defined during evaluation of the body script are removed and no longer spill into the function call.
    • NamespaceRef::new is fixed.

    Enhancements

    Engine API

    • Engine::consume_XXX methods are renamed to Engine::run_XXX to make meanings clearer. The consume_XXX API is deprecated.
    • Engine::register_type_XXX are now available even under no_object.
    • Added Engine::on_parse_token to allow remapping certain tokens during parsing.
    • Added Engine::const_empty_string to merge empty strings into a single instance.

    Custom Syntax

    • $symbol$ is supported in custom syntax to match any symbol.
    • Custom syntax with $block$, } or ; as the last symbol are now self-terminating (i.e. no need to attach a terminating ;).

    Dynamic Values

    • Dynamic::as_string and Dynamic::as_immutable_string are deprecated and replaced by into_string and into_immutable_string respectively.
    • Added a number of constants to Dynamic.
    • Added a number of constants and fromXXX constant methods to Dynamic.
    • Added sin, cos and tan for Decimal values.

    Decimal Values

    • parse_float(), PI() and E() now defer to Decimal under no_float if decimal is turned on.
    • Added log10() for Decimal.
    • ln for Decimal is now checked and won't panic.

    String Values

    • SmartString now uses LazyCompact instead of Compact to minimize allocations.
    • Added pop for strings.
    • Added ImmutableString::ptr_eq to test if two strings point to the same allocation.
    • The serde feature of SmartString is turned on under metadata to make Map serializable.

    Scope API

    • Scope::set_value now takes anything that implements Into<Cow<str> >.
    • Added Scope::is_constant to check if a variable is constant.
    • Added Scope::set_or_push to add a new variable only if one doesn't already exist.

    AST API

    • Added ASTNode::position.
    • ReturnType is removed in favor of option flags for Stmt::Return.
    • Stmt::Break and Stmt::Continue are merged into Stmt::BreakLoop via an option flag.
    • StaticVec is changed to keep three items inline instead of four.
    Open source →
  49. 1.0.6 28 Sep 2021
    Release notes

    Bug fixes

    • Eliminate unnecessary property write-back when accessed via a getter since property getters are assumed to be pure.
    • Writing to a property of an indexed valued obtained via an indexer now works properly by writing back the changed value via an index setter.

    Enhancements

    • MultiInputsStream, ParseState, TokenIterator, IdentifierBuilder and AccessMode are exported under the internals feature.
    Open source →
  50. 1.0.5 19 Sep 2021
    Release notes

    Bug fixes

    • FloatWrapper is no longer erroneously exported under no_float+internals.
    • The sign function now works properly for float values that are NaN.
    Open source →
  51. 1.0.4 03 Sep 2021
    Release notes
    • Fixed bug with catch variable used in catch block.
    Open source →
  52. 1.0.3 02 Sep 2021 withdrawn

    Nothing published for this version

  53. 1.0.2 17 Aug 2021
    Release notes

    Bug fixes

    • Fixed bug in method call followed by an array indexing.
    Open source →
  54. 1.0.1 06 Aug 2021
    Release notes

    Bug fixes

    • Fixed bug in using indexing/dotting inside index bracket.
    • while and loop statements are no longer considered pure (since a loop can go on forever and this is a side effect).
    Open source →
  55. 1.0.0 07 Jul 2021
    Release notes

    The official version 1.0.

    Almost the same version as 0.20.3 but with deprecated API's removed.

    Bug fixes

    • Fixed infinite loop in certain script optimizations.
    • Building for no-std no longer requires patching smartstring.
    • Parsing a lone return or throw without a semicolon at the end of a block no longer raises an error.

    Breaking changes

    • All deprecated API's (e.g. the RegisterFn and RegisterResultFn traits) are removed.
    • Module::set_id is split into Module::set_id and Module::clear_id pair.
    • begin, end, each, then, unless are no longer reserved keywords.

    Enhancements

    • New methods is_odd, is_even for integers, and is_zero for all numbers.
    • From<BTreeSet> and From<HashSet> are added for Dynamic, which create object maps with () values.
    Open source →
  56. 0.20.3 22 Jun 2021
    Release notes

    This version adds support to index into an integer number, treating it as a bit-field.

    Bug fixes

    • Fixed incorrect optimization regarding chain-indexing with non-numeric index.
    • Variable values are checked for over-sized violations after assignments and setters.

    Breaking changes

    • To keep the API consistent, strings are no longer iterable by default. Use the chars method to iterate through the characters in a string.
    • Dynamic::take_string and Dynamic::take_immutable_string are renamed to Dynamic::as_string and Dynamic::as_immutable_string respectively.

    New features

    • New syntax for for statement to include counter variable.
    • An integer value can now be indexed to get/set a single bit.
    • The bits method of an integer can be used to iterate through its bits.
    • New $bool$, $int$, $float$ and $string$ expression types for custom syntax.
    • New methods to_hex, to_octal and to_binary for integer numbers.
    • New methods to_upper, to_lower, make_upper, make_lower for strings/characters.
    Open source →
  57. 0.20.2 26 May 2021
    Release notes

    This version adds a number of convenience features:

    • Ability for a Dynamic to hold an i32 tag of arbitrary data

    • Simplifies dynamic properties access by falling back to an indexer (passing the name of the property as a string) when a property is not found.

    Bug fixes

    • Propagation of constants held in a custom scope now works properly instead of always replacing by ().

    Breaking changes

    • Engine::disable_doc_comments is removed because doc-comments are now placed under the metadata feature flag.
    • Registering a custom syntax now only requires specifying whether the Scope is adjusted (i.e. whether variables are added or removed). There is no need to specify the number of variables added/removed.
    • Assigning to a property of a constant is now allowed and no longer raise an EvalAltResult::ErrorAssignmentToConstant error. This is to facilitate the Singleton pattern. Registered setter functions are automatically guarded against setters calling on constants and will continue to raise errors unless the pure attribute is present (for plugins).
    • If a property getter/setter is not found, an indexer with string index, if any, is tried.
    • The indexers API (Engine::register_indexer_XXX and Module::set_indexer_XXX) are now also exposed under no_index.

    New features

    • Each Dynamic value can now contain arbitrary data (type i32) in the form of a tag. This is to use up otherwise wasted space in the Dynamic type.
    • A new internal feature no_smartstring to turn off SmartString for those rare cases that it is needed.
    • DynamicReadLock and DynamicWriteLoc are exposed under internals.
    • From< Shared< Locked<Dynamic> > > is added for Dynamic mapping directly to a shared value, together with support for Dynamic::from.
    • An indexer with string index acts as a fallback to a property getter/setter.

    Enhancements

    • Registering a custom syntax now only requires specifying whether the Scope is adjusted (i.e. whether variables are added or removed). This allows more flexibility for cases where the number of new variables declared depends on internal logic.
    • Putting a pure attribute on a plugin property/index setter now enables it to be used on constants.
    Open source →
  58. 0.20.1 02 May 2021
    Release notes

    This version enables functions to access constants declared at global level via the special global module.

    Bug fixes

    • Fixed bug when position is zero in insert and split_at methods for arrays.
    • Indexing operations with pure index values are no longer considered pure due to the possibility of indexers.

    Breaking changes

    • Dynamic::is_shared and Dynamic::is_locked are removed under the no_closure feature. They used to always return false.
    • Engine::call_fn now evaluates the AST before calling the function.
    • Engine::on_progress is disabled with unchecked.

    Enhancements

    • The crate no-std-compat is used to compile for no-std. This removes the need to use a special crate::stdlib namespace for std imports.

    New features

    • A module called global is automatically created to hold global-level constants, which can then be accessed from functions.
    • A new feature no_position is added to turn off position tracking during parsing to squeeze out the last drop of performance.
    Open source →
  59. 0.20.0 16 Apr 2021
    Release notes

    This version adds string interpolation with `... ${ ... } ...` syntax.

    switch statement cases can now have conditions.

    Negative indices for arrays and strings are allowed and now count from the end (-1 = last item/character).

    Bug fixes

    • Property setter op-assignments now work properly.
    • Off-by-one bug in Array::drain method with range is fixed.

    Breaking changes

    • Negative index to an array or string yields the appropriate element/character counting from the end.
    • The default _ case of a switch statement now must be the last case, together with two new error variants: EvalAltResult::WrongSwitchDefaultCase and EvalAltResult::WrongSwitchCaseCondition.
    • ModuleResolver trait methods take an additional parameter source_path that contains the path of the current environment. This is to facilitate loading other script files always from the current directory.
    • FileModuleResolver now resolves relative paths under the source path if there is no base path set.
    • FileModuleResolver::base_path now returns Option<&str> which is None if there is no base path set.
    • Doc-comments now require the metadata feature.

    Enhancements

    • Array::drain and Array::retain methods with predicate now scan the array in forward order instead of in reverse.

    New features

    • String interpolation support is added via the `... ${ ... } ...` syntax.
    • FileModuleResolver resolves relative paths under the parent path (i.e. the path holding the script that does the loading). This allows seamless cross-loading of scripts from a directory hierarchy instead of having all relative paths load from the current working directory.
    • Negative index to an array or string yields the appropriate element/character counting from the end.
    • switch statement cases can now have an optional if clause.
    Open source →
  60. 0.19.15 31 Mar 2021
    Release notes

    This version replaces all internal usage of HashMap with BTreeMap, which should result in some speed improvement because a BTreeMap is leaner when the number of items held is small. Most, if not all, collections in Rhai hold very few data items, so this is a typical scenario of many tiny-sized collections.

    The Rhai object map type, Map, used to be an alias to HashMap and is now aliased to BTreeMap instead. This is also because, in the vast majority of usage cases, the number of properties held by an object map is small.

    HashMap and BTreeMap have almost identical public API's so this change is unlikely to break existing code.

    SmartString is used to store identifiers (which tend to be short, fewer than 23 characters, and ASCII-based) because they can usually be stored inline. Map keys now also use SmartString.

    In addition, there is now support for line continuation in strings (put \ at the end of line) as well as multi-line literal strings (wrapped by back-ticks: `...`).

    Finally, all function signature/metadata methods are now grouped under the umbrella metadata feature. This avoids spending precious resources maintaining metadata for functions for the vast majority of use cases where such information is not required.

    Bug fixes

    • The feature flags no_index + no_object now compile without errors.

    Breaking changes

    • The traits RegisterFn and RegisterResultFn are removed. Engine::register_fn and Engine::register_result_fn are now implemented directly on Engine.
    • FnPtr::call_dynamic now takes &NativeCallContext instead of consuming it.
    • All Module::set_fn_XXX methods are removed, in favor of Module::set_native_fn.
    • Array::reduce and Array::reduce_rev now take a Dynamic as initial value instead of a function pointer.
    • protected, super are now reserved keywords.
    • The Module::set_fn_XXX API now take &str as the function name instead of Into<String>.
    • The reflections API such as Engine::gen_fn_signatures, Module::update_fn_metadata etc. are put under the metadata feature gate.
    • The shebang #! is now a reserved symbol.
    • Shebangs at the very beginning of script files are skipped when loading them.
    • SmartString is used for identifiers by default. Currently, a PR branch is pulled for no-std builds. The official crate will be used once SmartString is fixed to support no-std.
    • Map is now an alias to BTreeMap<SmartString, Dynamic> instead of HashMap because most object maps hold few properties.
    • EvalAltResult::FnWrongDefinition is renamed WrongFnDefinition for consistency.

    New features

    • Line continuation (via \) and multi-line literal strings (wrapped with `) support are added.
    • Rhai scripts can now start with a shebang #! which is ignored.

    Enhancements

    • Replaced all HashMap usage with BTreeMap for better performance because collections in Rhai are tiny.
    • Engine::register_result_fn no longer requires the successful return type to be Dynamic. It can now be any clonable type.
    • #[rhai_fn(return_raw)] can now return Result<T, Box<EvalAltResult> > where T is any clonable type instead of Result<Dynamic, Box<EvalAltResult> >.
    • Dynamic::clone_cast is added to simplify casting from a &Dynamic.
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive