From 144fe6b971d343d96c3f159b8279fd1ffc2a34bc Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Wed, 20 Aug 2025 05:13:37 -0400 Subject: [PATCH] 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. --- src/references/solution.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/references/solution.md b/src/references/solution.md index 5517c2d4..f7b469b4 100644 --- a/src/references/solution.md +++ b/src/references/solution.md @@ -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. +