The following primitive types are supported natively:
|Category||Equivalent Rust types|
|Floating-point number (disabled with |
|Fixed precision decimal number (requires |
|Immutable Unicode string|
|Object map (disabled with |
|Timestamp (disabled with |
|Dynamic value (i.e. can be anything)||the actual type||actual value|
|Shared value (a reference-counted, shared ||the actual type||actual value|
|System integer (current configuration)|
|System floating-point (current configuration, disabled with |
|Nothing/void/nil/null/Unit (or whatever it is called)|
All types are treated strictly separate by Rhai, meaning that
u32 are completely different -
they even cannot be added together. This is very similar to Rust.
The default integer type is
i64. If other integer types are not needed, it is possible to exclude them and make a
smaller build with the
If only 32-bit integers are needed, enabling the
only_i32 feature will remove support for all
integer types other than
This is useful on some 32-bit targets where using 64-bit integers incur a performance penalty.
If no floating-point is needed or supported, use the
no_float feature to remove it.
Some applications require fixed-precision decimal numbers, which can be enabled via the
Strings in Rhai are immutable, meaning that they can be shared but not modified.
ImmutableString type is a wrapper over
Arc<String> (depending on
Any modification done to a Rhai string causes the string to be cloned and the modifications made to the copy.