Print arrays and maps with to_debug.

This commit is contained in:
Stephen Chung
2020-11-30 11:20:51 +08:00
parent 65a4ceb3be
commit 1004bca5b5
9 changed files with 113 additions and 19 deletions

View File

@@ -11,6 +11,7 @@ is `T: Display + Debug`):
| ----------- | ---------------------------------------------- | ---------------------------- | -------------------------------------------------------------------- |
| `to_string` | <code>\|x: &mut T\| -> String</code> | `x.to_string()` | converts the custom type into a [string] |
| `print` | <code>\|x: &mut T\| -> String</code> | `x.to_string()` | converts the custom type into a [string] for the [`print`] statement |
| `to_debug` | <code>\|x: &mut T\| -> String</code> | `format!("{:?}", x)` | converts the custom type into a [string] in debug format |
| `debug` | <code>\|x: &mut T\| -> String</code> | `format!("{:?}", x)` | converts the custom type into a [string] for the [`debug`] statement |
| `+` | <code>\|s: &str, x: T\| -> String</code> | `format!("{}{}", s, x)` | concatenates the custom type with another [string] |
| `+` | <code>\|x: &mut T, s: &str\| -> String</code> | `x.to_string().push_str(s);` | concatenates another [string] with the custom type |