1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2024-12-11 13:18:43 +02:00

Updates PR with code formatting

Backticks for inline and single line code blocks / examples.
This commit is contained in:
Robin Stringer 2023-01-09 14:42:27 +00:00 committed by GitHub
parent 9cd5d25821
commit 6fac027dd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,14 +36,20 @@ Arrays:
*We can use literals to assign values to arrays.
*Demonstrate out of bounds errors by setting n to different values
e.g. a[n+15] = 11 // index out of bounds error since len is 10
```
a[n+15] = 11 // index out of bounds error since len is 10
```
*Efficient way to check n is in bounds:
assert!(n+20 < a.len()); // panics
```
assert!(n+20 < a.len()); // panics
```
*In the main function, the print statement contains the debug implementation {a :?}.
*Adding #, eg {a:#?}, invokes a "pretty printing" format, which can be easier to read.
*Adding `#`, eg `{a:#?}`, invokes a "pretty printing" format, which can be easier to read.
Tuples: