Add note on &T parameters.

This commit is contained in:
Stephen Chung
2020-08-06 21:11:24 +08:00
parent efe964f009
commit b8b1efd241
3 changed files with 10 additions and 4 deletions

View File

@@ -83,6 +83,8 @@ engine
***Note**: Rhai follows the convention that methods of custom types take a `&mut` first parameter
so that invoking methods can update the types. All other parameters in Rhai are passed by value (i.e. clones).*
**IMPORTANT: Rhai does NOT support normal references (i.e. `&T`) as parameters.**
Use the Custom Type in Scripts
-----------------------------
@@ -125,8 +127,8 @@ Under [`no_object`], however, the _method_ style of function calls
let result = engine.eval::<()>("let x = [1, 2, 3]; x.clear()")?;
```
[`type_of()`]
-------------
`type_of()` a Custom Type
-------------------------
[`type_of()`] works fine with custom types and returns the name of the type.

View File

@@ -42,3 +42,5 @@ let result = engine.eval::<String>(r#"let a = new_ts(); a.xyz = "42"; a.xyz"#)?;
println!("Answer: {}", result); // prints 42
```
**IMPORTANT: Rhai does NOT support normal references (i.e. `&T`) as parameters.**