Replace - with –
This commit is contained in:
@@ -16,7 +16,7 @@ prepare a Rhai script for this purpose as well as to control which functions/var
|
||||
When given an [`AST`], it is first evaluated, then the following items are exposed as members of the
|
||||
new [module]:
|
||||
|
||||
* Global variables - all variables exported via the `export` statement (those not exported remain hidden).
|
||||
* Global variables – all variables exported via the `export` statement (those not exported remain hidden).
|
||||
|
||||
* Functions not specifically marked `private`.
|
||||
|
||||
|
@@ -19,8 +19,8 @@ Manually creating a [module] is possible via the `Module` API.
|
||||
For the complete `Module` API, refer to the [documentation](https://docs.rs/rhai/{{version}}/rhai/struct.Module.html) online.
|
||||
|
||||
|
||||
Use Case 1 - Make the `Module` Globally Available
|
||||
------------------------------------------------
|
||||
Use Case 1 – Make the `Module` Globally Available
|
||||
------------------------------------------------------
|
||||
|
||||
`Engine::register_global_module` registers a shared [module] into the _global_ namespace.
|
||||
|
||||
@@ -62,8 +62,8 @@ engine.register_fn("inc", |x: i64| x + 1);
|
||||
engine.eval::<i64>("inc(41)")? == 42; // no need to import module
|
||||
```
|
||||
|
||||
Use Case 2 - Make the `Module` a Static Module
|
||||
---------------------------------------------
|
||||
Use Case 2 – Make the `Module` a Static Module
|
||||
---------------------------------------------------
|
||||
|
||||
`Engine::register_static_module` registers a [module] and under a specific module namespace.
|
||||
|
||||
@@ -122,8 +122,8 @@ engine.eval::<i64>("let x = 41; inc(x)")? == 42;
|
||||
```
|
||||
|
||||
|
||||
Use Case 3 - Make the `Module` Dynamically Loadable
|
||||
--------------------------------------------------
|
||||
Use Case 3 – Make the `Module` Dynamically Loadable
|
||||
--------------------------------------------------------
|
||||
|
||||
In order to dynamically load a custom module, there must be a [module resolver] which serves
|
||||
the module when loaded via `import` statements.
|
||||
|
@@ -100,8 +100,8 @@ When there is a mutable reference to the `this` object (i.e. the first argument)
|
||||
there can be no other immutable references to `args`, otherwise the Rust borrow checker will complain.
|
||||
|
||||
|
||||
Example - Passing a Callback to a Rust Function
|
||||
----------------------------------------------
|
||||
Example – Passing a Callback to a Rust Function
|
||||
----------------------------------------------------
|
||||
|
||||
The low-level API is useful when there is a need to interact with the scripting [`Engine`]
|
||||
within a function.
|
||||
@@ -147,8 +147,8 @@ let result = engine.eval::<i64>(
|
||||
```
|
||||
|
||||
|
||||
TL;DR - Why `read_lock` and `write_lock`
|
||||
---------------------------------------
|
||||
TL;DR – Why `read_lock` and `write_lock`
|
||||
---------------------------------------------
|
||||
|
||||
The `Dynamic` API that casts it to a reference to a particular data type is `read_lock`
|
||||
(for an immutable reference) and `write_lock` (for a mutable reference).
|
||||
|
@@ -108,7 +108,7 @@ let x: MyStruct = from_dynamic(&result)?;
|
||||
Cannot Deserialize Shared Values
|
||||
-------------------------------
|
||||
|
||||
A [`Dynamic`] containing a _shared_ value cannot be deserialized - i.e. it will give a type error.
|
||||
A [`Dynamic`] containing a _shared_ value cannot be deserialized – i.e. it will give a type error.
|
||||
|
||||
Use `Dynamic::flatten` to obtain a cloned copy before deserialization
|
||||
(if the value is not shared, it is simply returned and not cloned).
|
||||
|
@@ -9,7 +9,7 @@ Avoid `String`
|
||||
|
||||
As must as possible, avoid using `String` parameters in functions.
|
||||
|
||||
Each `String` argument is cloned during every single call to that function - and the copy
|
||||
Each `String` argument is cloned during every single call to that function – and the copy
|
||||
immediately thrown away right after the call.
|
||||
|
||||
Needless to say, it is _extremely_ inefficient to use `String` parameters.
|
||||
|
Reference in New Issue
Block a user