Skip to content

Commit 0e57f4e

Browse files
committed
Add speaker note regarding passing slices instead
This section covers both references and slices, but the exercise focuses on references. This speaker note briefly discusses the option to use slices instead, and a cost of doing so.
1 parent 301170f commit 0e57f4e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/references/solution.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@
1010
element. This is because we're iterating using a mutable reference to an
1111
array, which causes the `for` loop to give mutable references to each element.
1212

13+
- It is also possible to take slice references here, e.g.,
14+
`fn
15+
magnitude(vector: &[f64]) -> f64`. This makes the function more general,
16+
at the cost of a runtime length check.
17+
1318
</details>

0 commit comments

Comments
 (0)