1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-10 00:44:21 +02:00

Clarify default vs debug output.

This commit is contained in:
Martin Geisler 2023-01-11 10:49:21 +01:00 committed by GitHub
parent 6fac027dd6
commit 587645db6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,7 +47,7 @@ a[n+15] = 11 // index out of bounds error since len is 10
assert!(n+20 < a.len()); // panics
```
*In the main function, the print statement contains the debug implementation {a :?}.
*In the main function, the print statement asks for the debug implementation with the `?` format parameter: `{a}` gives default output, `{a:?}` gives debug output.
*Adding `#`, eg `{a:#?}`, invokes a "pretty printing" format, which can be easier to read.