Module resolver returns shared module.

This commit is contained in:
Stephen Chung
2020-11-07 23:33:21 +08:00
parent d5d70367fa
commit b3d318ef7f
20 changed files with 158 additions and 136 deletions

View File

@@ -29,6 +29,8 @@ Loads a script file (based off the current directory) with `.rhai` extension.
All functions in the _global_ namespace, plus all those defined in the same module,
are _merged_ into a _unified_ namespace.
Modules are also _cached_ so a script file is only evaluated _once_, even when repeatedly imported.
```rust
------------------
| my_module.rhai |
@@ -122,10 +124,6 @@ m::greet(); // prints "hello! from module!"
The base directory can be changed via the `FileModuleResolver::new_with_path` constructor function.
### Returning a module instead
`FileModuleResolver::create_module` loads a script file and returns a module with the standard behavior.
`StaticModuleResolver`
---------------------