3.5 KiB
3.5 KiB
Rust Examples
{{#include ../../links.md}}
A number of examples can be found in the examples
folder:
Example | Description |
---|---|
arrays_and_structs |
Shows how to register a custom Rust type and using [arrays] on it. |
custom_types_and_methods |
Shows how to register a custom Rust type and methods for it. |
hello |
Simple example that evaluates an expression and prints the result. |
no_std |
Example to test out no-std builds.The [ no_std ] feature is required to build in no-std . |
reuse_scope |
Evaluates two pieces of code in separate runs, but using a common [Scope ]. |
rhai_runner |
Runs each filename passed to it as a Rhai script. |
serde |
Example to serialize and deserialize Rust types with serde .The [ serde ] feature is required to run. |
simple_fn |
Shows how to register a simple function. |
strings |
Shows different ways to register functions taking string arguments. |
repl |
A simple REPL, interactively evaluate statements from stdin. |
The repl
example is a particularly good one as it allows one to interactively try out Rhai's
language features in a standard REPL (Read-Eval-Print Loop).
Running Examples
Examples can be run with the following command:
cargo run --example {example_name}