Skip to content

v1.16.0

Compare
Choose a tag to compare
@schungx schungx released this 09 Sep 09:09
· 333 commits to main since this release
7c6ba38

This version is a general code cleanup such that it relies less on obscure hacks unless those tricks provide genuine performance benefits. It should make the code base easier to follow for new contributors.

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.