Repository navigation
v.0.19.15
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.
Version 0.19.15 released to crates.io.
Bug fixes
- The feature flags
no_index + no_objectnow compile without errors.
Breaking changes
- The traits
RegisterFnandRegisterResultFnare removed.Engine::register_fnandEngine::register_result_fnare now implemented directly onEngine. FnPtr::call_dynamicnow takes&NativeCallContextinstead of consuming it.- All
Module::set_fn_XXXmethods are removed, in favor ofModule::set_native_fn. Array::reduceandArray::reduce_revnow take aDynamicas initial value instead of a function pointer.protected,superare now reserved keywords.- The
Module::set_fn_XXXAPI now take&stras the function name instead ofInto<String>. - The reflections API such as
Engine::gen_fn_signatures,Module::update_fn_metadataetc. are put under themetadatafeature gate. - The shebang
#!is now a reserved symbol. - Shebangs at the very beginning of script files are skipped when loading them.
SmartStringis used for identifiers by default. Currently, a PR branch is pulled forno-stdbuilds. The official crate will be used onceSmartStringis fixed to supportno-std.Mapis now an alias toBTreeMap<SmartString, Dynamic>instead ofHashMapbecause most object maps hold few properties.EvalAltResult::FnWrongDefinitionis renamedWrongFnDefinitionfor 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
HashMapusage withBTreeMapfor better performance because collections in Rhai are tiny. Engine::register_result_fnno 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>>whereTis any clonable type instead ofResult<Dynamic, Box<EvalAltResult>>.Dynamic::clone_castis added to simplify casting from a&Dynamic.