Skip to content

Commit 31bfaac

Browse files
Add modifications from review
1 parent be6b80b commit 31bfaac

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

courses/rust_essentials/050_tuples_and_arrays/01_arrays.rst

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ What Is an Array?
1717
Basics
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
-----------------------------------
3838
Safety 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
-------------------
7170
Iteration
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 ({}).

courses/rust_essentials/050_tuples_and_arrays/02_tuples.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ Tuples
66
Basics
77
--------------------
88

9-
- Groups together values of **different types**
9+
- Group together values of **different types**
1010
- Like arrays, have a **fixed length**
11-
- Fields are accessed via dot notation by their index, starting from :rust:`0`
11+
- Elements are accessed via dot notation by their index
12+
- Starting from :rust:`0`
1213

1314
.. code:: rust
1415
1516
// Tuple with an i8 and a bool
1617
let alien_report: (i8, bool) = (3, false);
1718
println!("Number of tentacles: {}", alien_report.0);
18-
println!("...is the creature hostile: {}", alien_report.1);
19+
println!("Hostile? {}", alien_report.1);

courses/rust_essentials/050_tuples_and_arrays/99_summary.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ What We Covered
1818
- Fields are accessed via dot notation followed by their index
1919
- Starting from :rust:`0`
2020

21+
-----------------------------
22+
What We Covered (Continued)
23+
-----------------------------
24+
2125
- **Patterns and Destructuring**
2226
- Used for clarity, simplicity and skipping unneeded values
2327
- Irrefutable patterns are patterns guaranteed to match the structure
24-
- Skip specific element using (:rust:`_`) and multiple elements using (:rust:`..`)
28+
- Skip an element using (:rust:`_`) and multiple elements using (:rust:`..`)
2529
- Destructuring can be used as an assignment operation
2630
- Use a pattern within a pattern to destructure an array of arrays
31+

0 commit comments

Comments
 (0)