Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Rhai - An embedded scripting language for Rust.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt
NotificationsYou must be signed in to change notification settings

rhaiscript/rhai

Repository files navigation

GitHub last commitBuild StatusStarsLicensecrates.iocrates.ioAPI DocsVS Code plugin installsSublime Text package downloadsDiscord ChatZulip ChatReddit Channel

Rhai logo

Rhai is an embedded scripting language and evaluation engine for Rust that gives a safe and easy wayto add scripting to any application.

Targets and builds

  • All CPU and O/S targets supported by Rust, including:
    • WebAssembly (WASM)
    • no-std
  • Minimum Rust version 1.66.0

Standard features

Protected against attacks

  • Don't Panic guarantee - Any panic is a bug. Rhai subscribes to the motto that a library should never panic the host system, and is coded with this in mind.
  • Sand-boxed - the scripting engine, if declared immutable, cannot mutate the containing environment unlessexplicitly permitted.
  • Rugged - protected against malicious attacks (such asstack-overflow,over-sized data, andrunaway scripts etc.) that may come from untrusted third-party user-land scripts.
  • Track script evaluationprogress and manually terminate a script run.
  • Passes Miri.

For those who actually want their own language

Example

Thescripts subdirectory contains sample Rhai scripts.

Below is the standardFibonacci example for scripting languages:

// This Rhai script calculates the n-th Fibonacci number using a// really dumb algorithm to test the speed of the scripting engine.constTARGET=28;constREPEAT=5;constANSWER=317_811;fnfib(n){ifn<2{n}else{fib(n-1)+fib(n-2)}}print(`Running Fibonacci(${TARGET}) x${REPEAT} times...`);print("Ready... Go!");letresult;letnow=timestamp();fornin0..REPEAT{result=fib(TARGET);}print(`Finished. Run time =${now.elapsed} seconds.`);print(`Fibonacci number #${TARGET} =${result}`);ifresult!=ANSWER{print(`The answer is WRONG! Should be${ANSWER}!`);}

Project Site

rhai.rs

Documentation

SeeThe Rhai Book for details on the Rhai scripting engine and language.

Playground

AnOnline Playground is available with syntax-highlighting editor,powered by WebAssembly.

Scripts can be evaluated directly from the editor.

License

Licensed under either of the following, at your choice:

Unless explicitly stated otherwise, any contribution intentionally submittedfor inclusion in this crate, as defined in the Apache-2.0 license, shallbe dual-licensed as above, without any additional terms or conditions.


[8]ページ先頭

©2009-2025 Movatter.jp