What is Rhai
❱
Features
Supported Targets and Builds
What Rhai Isn't
Licensing
Related Resources
Getting Started
❱
Online Playground
Install the Rhai Crate
Optional Features
Special Builds
❱
Performance
Minimal
no-std
WebAssembly (WASM)
Packaged Utilities
Examples
❱
Rust
Scripts
Using the Engine
❱
Hello World in Rhai – Evaluate a Script
Compile to AST for Repeated Evaluations
Call a Rhai Function from Rust
Create a Rust Closure from a Rhai Function
Evaluate Expressions Only
Raw Engine
Scope – Initializing and Maintaining State
Engine Configuration Options
Extend Rhai with Rust
❱
Traits
Register a Rust Function
❱
String Parameters in Rust Functions
Register a Generic Rust Function
Register a Fallible Rust Function
Override a Built-in Function
Operator Overloading
Register any Rust Type and its Methods
❱
Property Getters and Setters
Indexers
Disable Custom Types
Printing Custom Types
Modules
❱
Create from Rust
Create from AST
Module Resolvers
❱
Custom Module Resolvers
Self-Contained AST
Plugins
❱
Export a Rust Module
Export a Rust Function
Packages
❱
Built-in Packages
Custom Packages
Rhai Language Reference
❱
Comments
❱
Doc-Comments
Values and Types
❱
Dynamic Values
❱
type_of()
Serialization/Deserialization with serde
Numbers
❱
Operators
Functions
Value Conversions
Strings and Characters
❱
Built-in Functions
Arrays
Object Maps
❱
Parse from JSON
Special Support for OOP
Time-Stamps
Keywords
Statements
Variables
Constants
Logic Operators
Assignment Operators
If Statement
Switch Expression
While Loop
Do Loop
Loop Statement
For Loop
❱
Iterators for Custom Types
Return Values
Throw Exception on Error
Catch Exceptions
Functions
❱
Call Method as Function
Overloading
Namespaces
Function Pointers
Currying
Anonymous Functions
Closures
Print and Debug
Modules
❱
Export Variables, Functions and Sub-Modules
Import Modules
Eval Function
Safety and Protection
❱
Checked Arithmetic
Sand-Boxing
Maximum Length of Strings
Maximum Size of Arrays
Maximum Size of Object Maps
Maximum Number of Operations
❱
Tracking Progress and Force-Termination
Maximum Number of Modules
Maximum Call Stack Depth
Maximum Statement Depth
Script Optimization
❱
Optimization Levels
Re-Optimize an AST
Eager Function Evaluation
Side-Effect Considerations
Volatility Considerations
Subtle Semantic Changes
Usage Patterns
❱
Object-Oriented Programming (OOP)
Working With Rust Enums
Loadable Configuration
Control Layer
Singleton Command
Multi-Layer Functions
One Engine Instance Per Call
Scriptable Event Handler with State
Dynamic Constants Provider
Advanced Topics
❱
Capture Scope for Function Call
Low-Level API
Variable Resolver
Use as DSL
❱
Disable Keywords and/or Operators
Custom Operators
Extending with Custom Syntax
Multiple Instantiation
Functions Metadata
❱
Generate Function Signatures
Export Metadata to JSON
External Tools
❱
Online Playground
rhai-doc
Appendix
❱
Keywords
Operators and Symbols
Literals
Light (default)
Rust
Coal
Navy
Ayu
Rhai - Rust 的嵌入脚本 - Embedded Scripting for Rust
书馆
Getting Started
This section shows how to install the Rhai crate into a Rust application.