1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-08-25 20:29:09 +02:00

Add speaker note regarding passing slices instead (#2851)

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.
This commit is contained in:
Dustin J. Mitchell
2025-08-20 05:13:37 -04:00
committed by GitHub
parent 301170f17e
commit 144fe6b971

View File

@@ -10,4 +10,9 @@
element. This is because we're iterating using a mutable reference to an
array, which causes the `for` loop to give mutable references to each element.
- It is also possible to take slice references here, e.g.,
`fn
magnitude(vector: &[f64]) -> f64`. This makes the function more general,
at the cost of a runtime length check.
</details>