Rhai v0.19.15 Release Notes
-
This version replaces all internal usage of
HashMap
withBTreeMap
, which should result in some speed improvement because aBTreeMap
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 toHashMap
and is now aliased toBTreeMap
instead. This is also because, in the vast majority of usage cases, the number of properties held by an object map is small.HashMap
andBTreeMap
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 useSmartString
.๐ 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
andRegisterResultFn
are removed.Engine::register_fn
andEngine::register_result_fn
are now implemented directly onEngine
. FnPtr::call_dynamic
now takes&NativeCallContext
instead of consuming it.- All
Module::set_fn_XXX
methods are removed, in favor ofModule::set_native_fn
. Array::reduce
andArray::reduce_rev
now take aDynamic
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 ofInto<String>
. - The reflections API such as
Engine::gen_fn_signatures
,Module::update_fn_metadata
etc. are put under themetadata
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 forno-std
builds. The official crate will be used onceSmartString
is fixed to supportno-std
. Map
is now an alias toBTreeMap<SmartString, Dynamic>
instead ofHashMap
because most object maps hold few properties.EvalAltResult::FnWrongDefinition
is renamedWrongFnDefinition
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 withBTreeMap
for better performance because collections in Rhai are tiny. Engine::register_result_fn
no longer requires the successful return type to beDynamic
. It can now be any clonable type.#[rhai_fn(return_raw)]
can now returnResult<T, Box<EvalAltResult>>
whereT
is any clonable type instead ofResult<Dynamic, Box<EvalAltResult>>
.- ๐ฏ
Dynamic::clone_cast
is added to simplify casting from a&Dynamic
.
- The feature flags