Built-In Packages

Engine::new creates an Engine with the StandardPackage loaded.

Engine::new_raw creates an Engine with no package loaded.

PackageDescriptionIn CoreIn Standard
LanguageCorePackagecore functions for the Rhai languageyesyes
ArithmeticPackagearithmetic operators (e.g. +, -, *, /) for numeric types that are not built in (e.g. u16)yesyes
BitFieldPackagebasic bit-field functionsnoyes
BasicIteratorPackagenumeric ranges (e.g. range(1, 100, 5)), iterators for arrays, strings, bit-fields and object mapsyesyes
LogicPackagelogical and comparison operators (e.g. ==, >) for numeric types that are not built in (e.g. u16)noyes
BasicStringPackagebasic string functions (e.g. print, debug, len) that are not built inyesyes
BasicTimePackagebasic time functions (e.g. timestamps, not available under no_time or no_std)noyes
MoreStringPackageadditional string functions, including converting common types to stringnoyes
BasicMathPackagebasic math functions (e.g. sin, sqrt)noyes
BasicArrayPackagebasic array functions (not available under no_index)noyes
BasicBlobPackagebasic BLOB functions (not available under no_index)noyes
BasicMapPackagebasic object map functions (not available under no_object)noyes
BasicFnPackagebasic methods for function pointersyesyes
DebuggingPackagebasic functions for debugging (requires debugging)yesyes
CorePackagebasic essentialsyesyes
StandardPackagestandard library (default for Engine::new)noyes

CorePackage

If only minimal functionalities are required, register the CorePackage instead.

use rhai::Engine;
use rhai::packages::{Package, CorePackage};

let mut engine = Engine::new_raw();
let package = CorePackage::new();

// Register the package into the 'Engine'.
package.register_into_engine(&mut engine);