The following primitive types are supported natively:
|Category||Equivalent Rust types|
|Floating-point number (disabled with |
|Immutable Unicode string|
|Object map (disabled with |
|Timestamp (implemented in the |
|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.
Strings in Rhai are immutable, meaning that they can be shared but not modified. In actual, the
is an alias to
Arc<String> (depending on the
Any modification done to a Rhai string will cause the string to be cloned and the modifications made to the copy.
to_string function converts a standard type into a string for display purposes.
to_debug function converts a standard type into a string in debug format.