Rhai v1.9.0 Release Notes
-
The minimum Rust version is now
1.60.0
in order to use thedep:
syntax for dependencies.๐ Bug fixes
- โก๏ธ
switch
cases with conditions that evaluate to constant()
no longer optimize tofalse
(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 toimport
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 currentEngine
.
๐ New features
๐ New feature flags
- 0๏ธโฃ 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 themetadata
feature) are now collected as the script file's module documentation. - ๐
AST
andModule
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 theCustomType
trait (which usesTypeBuilder
to register the API functions).
๐ฆ Simpler Package API
- It is now easier to register packages via the
Package::register_into_engine
andPackage::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
statementswitch
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
andExpression::eval_with_context_raw
are added to allow for not rewinding theScope
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
andFnNameSpace::is_global_namespace
are added for convenience.- ๐
Iterator<Item=T>
type for functions metadata is simplified toIterator<T>
. - ๐
Scope::remove
is added to remove a variable from aScope
, returning its value. - The code base is cleaner by running it through Clippy.
- ๐
ParseError::err_type
andParseError::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.
- โก๏ธ