Add include_standard_packages to Definitions.

This commit is contained in:
Stephen Chung
2022-07-29 13:39:51 +08:00
parent 52edded841
commit 13a1147dea
8 changed files with 621 additions and 96 deletions

View File

@@ -44,5 +44,21 @@ fn main() -> Result<(), Box<EvalAltResult>> {
.write_to_file("examples/definitions/.rhai/all_in_one.d.rhai")
.unwrap();
// Skip standard packages if not needed (e.g. they are provided elsewhere).
engine
.definitions_with_scope(&scope)
.include_standard_packages(false)
.write_to_file("examples/definitions/.rhai/all_in_one_without_standard.d.rhai")
.unwrap();
// Write function definitions as JSON.
let json = engine
.definitions()
.include_standard_packages(false)
.json()
.unwrap();
std::fs::write("examples/definitions/.rhai/defs.json", json).unwrap();
Ok(())
}