Expand packages and raw Engine write-up.

This commit is contained in:
Stephen Chung
2020-08-23 17:22:39 +08:00
parent 196e145c96
commit e2f271644a
10 changed files with 127 additions and 12 deletions

View File

@@ -5,6 +5,14 @@ Create a Custom Package
Sometimes specific functionalities are needed, so custom packages can be created.
A custom package is a convenient means to gather up a number of functions for later use.
An [`Engine`] only needs to `Engine::load_package` the custom package once to gain access
to the entire set of functions within.
Loading a package into an [`Engine`] is functionally equivalent to calling `Engine::register_fn` etc.
on _each_ of the functions inside the package. But because packages are _shared_, loading an existing
package is _much_ cheaper than registering all the functions one by one.
The macro `rhai::def_package!` is used to create a new custom package.