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
BasicIteratorPackagenumeric ranges (e.g. range(1, 10))yesyes
LogicPackagelogical and comparison operators (e.g. ==, >) for numeric types that are not built in (e.g. u16)yesyes
BasicStringPackagebasic string functions (e.g. print, debug, len) that are not built inyesyes
BasicTimePackagebasic time functions (e.g. timestamps)yesyes
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
BasicMapPackagebasic object map functions (not available under no_object)noyes
BasicFnPackagebasic methods for function pointers.yesyes
CorePackagebasic essentialsyesyes
StandardPackagestandard library (default for Engine::new)noyes


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

fn main() {
use rhai::Engine;
use rhai::packages::{Package, CorePackage};

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

// Register the package into the 'Engine' by converting it into a shared module.