Fix pipes in tables.

This commit is contained in:
Stephen Chung 2020-06-21 10:37:17 +08:00
parent 6121aaec9d
commit 00c4052636
3 changed files with 20 additions and 15 deletions

View File

@ -9,6 +9,11 @@ Breaking changes
* The trait function `ModuleResolver::resolve` no longer takes a `Scope` as argument. * The trait function `ModuleResolver::resolve` no longer takes a `Scope` as argument.
Enhancements
------------
* [The Rhai Book](https://schungx.github.io/rhai) is online. Most content in the original `README` was transferred to the Book.
Version 0.15.1 Version 0.15.1
============== ==============

View File

@ -36,13 +36,13 @@ ts != 42; // true - types cannot be compared
Boolean operators Boolean operators
----------------- -----------------
| Operator | Description | | Operator | Description |
| -------- | ------------------------------------- | | ----------------- | ------------------------------------- |
| `!` | Boolean _Not_ | | `!` | Boolean _Not_ |
| `&&` | Boolean _And_ (short-circuits) | | `&&` | Boolean _And_ (short-circuits) |
| `||` | Boolean _Or_ (short-circuits) | | <code>\|\|</code> | Boolean _Or_ (short-circuits) |
| `&` | Boolean _And_ (doesn't short-circuit) | | `&` | Boolean _And_ (doesn't short-circuit) |
| `|` | Boolean _Or_ (doesn't short-circuit) | | <code>\|</code> | Boolean _Or_ (doesn't short-circuit) |
Double boolean operators `&&` and `||` _short-circuit_, meaning that the second operand will not be evaluated Double boolean operators `&&` and `||` _short-circuit_, meaning that the second operand will not be evaluated
if the first one already proves the condition wrong. if the first one already proves the condition wrong.

View File

@ -6,11 +6,11 @@ Printing for Custom Types
To use custom types for [`print`] and [`debug`], or convert its value into a [string], it is necessary that the following To use custom types for [`print`] and [`debug`], or convert its value into a [string], it is necessary that the following
functions be registered (assuming the custom type is `T : Display + Debug`): functions be registered (assuming the custom type is `T : Display + Debug`):
| Function | Signature | Typical implementation | Usage | | Function | Signature | Typical implementation | Usage |
| ----------- | ------------------------------------------------ | ------------------------------------- | --------------------------------------------------------------------------------------- | | ----------- | ------------------------------------------------------------- | ------------------------------------- | --------------------------------------------------------------------------------------- |
| `to_string` | `|s: &mut T| -> ImmutableString` | `s.to_string().into()` | Converts the custom type into a [string] | | `to_string` | <code>\|s: &mut T\| -> ImmutableString</code> | `s.to_string().into()` | Converts the custom type into a [string] |
| `print` | `|s: &mut T| -> ImmutableString` | `s.to_string().into()` | Converts the custom type into a [string] for the [`print`](#print-and-debug) statement | | `print` | <code>\|s: &mut T\| -> ImmutableString</code> | `s.to_string().into()` | Converts the custom type into a [string] for the [`print`](#print-and-debug) statement |
| `debug` | `|s: &mut T| -> ImmutableString` | `format!("{:?}", s).into()` | Converts the custom type into a [string] for the [`debug`](#print-and-debug) statement | | `debug` | <code>\|s: &mut T\| -> ImmutableString</code> | `format!("{:?}", s).into()` | Converts the custom type into a [string] for the [`debug`](#print-and-debug) statement |
| `+` | `|s1: ImmutableString, s: T| -> ImmutableString` | `s1 + s` | Append the custom type to another [string], for `print("Answer: " + type);` usage | | `+` | <code>\|s1: ImmutableString, s: T\| -> ImmutableString</code> | `s1 + s` | Append the custom type to another [string], for `print("Answer: " + type);` usage |
| `+` | `|s: T, s2: ImmutableString| -> ImmutableString` | `s.to_string().push_str(&s2).into();` | Append another [string] to the custom type, for `print(type + " is the answer");` usage | | `+` | <code>\|s: T, s2: ImmutableString\| -> ImmutableString</code> | `s.to_string().push_str(&s2).into();` | Append another [string] to the custom type, for `print(type + " is the answer");` usage |
| `+=` | `|s1: &mut ImmutableString, s: T|` | `s1 += s.to_string()` | Append the custom type to an existing [string], for `s += type;` usage | | `+=` | <code>\|s1: &mut ImmutableString, s: T\|</code> | `s1 += s.to_string()` | Append the custom type to an existing [string], for `s += type;` usage |