Refine docs.
This commit is contained in:
@@ -45,6 +45,15 @@ The following methods (mostly defined in the [`BasicArrayPackage`][packages] but
|
||||
| `truncate` | target length | cuts off the array at exactly a specified length (discarding all subsequent elements) |
|
||||
|
||||
|
||||
Use Custom Types With Arrays
|
||||
---------------------------
|
||||
|
||||
To use a [custom type] with arrays, a number of array functions need to be manually implemented,
|
||||
in particular `push`, `pad` and the `==` operator (in order to support the `in` operator).
|
||||
|
||||
See the section on [custom types] for more details.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
@@ -123,9 +132,3 @@ y.clear(); // empty the array
|
||||
|
||||
y.len == 0;
|
||||
```
|
||||
|
||||
`push` and `pad` are only defined for standard built-in types. For custom types, type-specific versions must be registered:
|
||||
|
||||
```rust
|
||||
engine.register_fn("push", |list: &mut Array, item: MyType| list.push(Box::new(item)) );
|
||||
```
|
||||
|
Reference in New Issue
Block a user