Value Types

The following primitive value types are supported natively.

System integer"i32" or "i64""42", "123" etc.
Other integer number"i32", "u64" etc."42", "123" etc.
Integer numeric range"range", "range=""2..7", "0..=15" etc.
Floating-point number"f32" or "f64""123.4567" etc.
Fixed precision decimal number"decimal""42", "123.4567" etc.
Boolean value"bool""true" or "false"
Unicode character"char""A", "x" etc.
Immutable Unicode string"string""hello" etc.
Array"array""[ 1, 2, 3 ]" etc.
Byte array – BLOB"blob""[01020304abcd]" etc.
Object map"map""#{ "a": 1, "b": true }" etc.
Function pointer"Fn""Fn(foo)" etc.
Dynamic value (i.e. can be anything)the actual typeactual value
Shared value (a reference-counted, shared dynamic value, created via automatic curryingthe actual typeactual value
Nothing/void/nil/null/Unit (or whatever it is called)"()""" (empty string)

All types are distinct

All types are treated strictly distinct by Rhai, meaning that i32 and i64 and u32 are completely different. They cannot even be added together.

This is very similar to Rust.


Strings in Rhai are immutable, meaning that they can be shared but not modified.

Any modification done to a Rhai string causes the string to be cloned and the modifications made to the copy.

Tip: Convert to string

The to_string function converts a standard type into a string for display purposes.

The to_debug function converts a standard type into a string in debug format.