reorganize module

This commit is contained in:
Timur Gordon
2025-04-04 08:28:07 +02:00
parent 1ea37e2e7f
commit 939b6b4e57
375 changed files with 7580 additions and 191 deletions

View File

@@ -0,0 +1,34 @@
Maximum Length of Strings
=========================
{{#include ../links.md}}
Rhai by default does not limit how long a [string] can be.
This can be changed via the [`Engine::set_max_string_size`][options] method, with zero being
unlimited (the default).
A script attempting to create a [string] literal longer than the maximum length will terminate with
a parse error.
Any script operation that produces a [string] longer than the maximum also terminates the script
with an error.
This check can be disabled via the [`unchecked`] feature for higher performance (but higher risks as well).
```rust
let mut engine = Engine::new();
engine.set_max_string_size(500); // allow strings only up to 500 bytes long (in UTF-8 format)
engine.set_max_string_size(0); // allow unlimited string length
```
```admonish danger.small "Maximum length"
Be conservative when setting a maximum limit and always consider the fact that a registered function may grow
a string's length without Rhai noticing until the very end.
For instance, the built-in `+` operator for strings concatenates two strings together to form one longer string;
if both strings are _slightly_ below the maximum length limit, the resultant string may be almost _twice_ the maximum length.
```