mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-19 00:43:18 +02:00
Updates PR with code formatting
Backticks for inline and single line code blocks / examples.
This commit is contained in:
parent
9cd5d25821
commit
6fac027dd6
@ -36,14 +36,20 @@ Arrays:
|
|||||||
*We can use literals to assign values to arrays.
|
*We can use literals to assign values to arrays.
|
||||||
|
|
||||||
*Demonstrate out of bounds errors by setting n to different values
|
*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:
|
*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 :?}.
|
*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:
|
Tuples:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user