From 0e57f4e861479d6471b39d15d946d13c1b869061 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Sun, 17 Aug 2025 15:29:51 -0400 Subject: [PATCH] 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. --- src/references/solution.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/references/solution.md b/src/references/solution.md index 5517c2d401bc..f7b469b42b6d 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. +