@@ -17,12 +17,12 @@ What Is an Array?
1717Basics
1818--------------------
1919
20- - Allocated on the stack, they're fast!
20+ - Allocated on the stack - they're fast!
2121- *Size * is **fixed ** and defined at **compile-time **
2222- *Length * of an array is part of its type
23- - :rust: `[T;N] ` holds :rust: `N ` elements of type T
23+ - :rust: `[T;N] ` holds :rust: `N ` elements of type :rust: ` T `
2424 - :rust: `[u8;3] ` and :rust: `[u8;4] ` are considered two different types
25- - Indexes start at :rust: `0 ` (Range is :rust: `0 ` to :rust: `N-1 `)
25+ - Index starts at :rust: `0 ` (range is :rust: `0 ` to :rust: `N-1 `)
2626
2727.. code :: rust
2828
@@ -32,15 +32,15 @@ Basics
3232
3333 .. note ::
3434
35- Reminder: :rust: `mut ` is required for modification
35+ Remember, :rust: `mut ` is required for modification
3636
3737-----------------------------------
3838Safety and Initialization
3939-----------------------------------
4040
4141**Safety **
4242
43- - Compile-time and runtime **out-of-bounds checks **
43+ - Compile-time and run-time **out-of-bounds checks **
4444 - Accessing an element beyond the defined length will cause a *panic *
4545 - A *panic * is a form of program termination
4646
@@ -56,33 +56,44 @@ Safety and Initialization
5656 let bools = [true, false, true]; // Boolean literals
5757
5858 * Or using *array repeat expression * :rust: `[value; N] `:
59- * With size * N * , known at compile-time
59+ * With size :rust: ` N ` , known at compile-time
6060 * Where every element is *value *
6161
6262.. code :: rust
6363
6464 let elements: [i8; 5] = [0; 5];
6565
6666 * Assignment is **not ** limited to literals
67- * Not restricted to hard-coded values
6867 * Can use variables, function calls, or expressions
6968
7069-------------------
7170Iteration
7271-------------------
7372
74- - :rust: `for ` statement natively supports iterating over arrays
73+ * :rust: `for ` statement natively supports iterating over arrays
7574
76- .. code :: rust
75+ * Given an array
76+
77+ .. code :: rust
7778
7879 let primes = [2, 3, 5, 7, 11, 13, 17];
80+
81+ * Iteration by value would look like
82+
83+ .. code :: rust
84+
7985 for prime in primes {
80- // ... do something
86+ println!("{}", prime);
8187 }
8288
89+ * While index-based looping would look like
90+
91+ .. code :: rust
92+
8393 for ii in 0..primes.len() {
84- // ... do something, using primes[ii]
94+ println!("{}", primes[ii]);
8595 }
96+
8697 .. container :: speakernote
8798
8899 Arrays do not implement the default Display trait ({}).
0 commit comments