From a028d347ba9fbada143efd4dff3758610f84254c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20T=C3=A4nzer?= Date: Sun, 24 Aug 2025 21:23:40 +0200 Subject: [PATCH] Fix wrong reference to variable in listing In the listing the variable is called `i` not `n_ref` --- src/ch08-01-vectors.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ch08-01-vectors.md b/src/ch08-01-vectors.md index 6b1d04d135..8e76f7c430 100644 --- a/src/ch08-01-vectors.md +++ b/src/ch08-01-vectors.md @@ -171,7 +171,7 @@ to use a `for` loop to get immutable references to each element in a vector of -To read the number that `n_ref` refers to, we have to use the `*` dereference operator to get to the value in `n_ref` before we can add 1 to it, as covered in ["Dereferencing a Pointer Accesses Its Data"][deref]. +To read the number that `i` refers to, we have to use the `*` dereference operator to get to the value in `i` before we can add 1 to it, as covered in ["Dereferencing a Pointer Accesses Its Data"][deref]. We can also iterate over mutable references to each element in a mutable vector in order to make changes to all the elements. The `for` loop in Listing 8-8 @@ -185,7 +185,7 @@ will add `50` to each element. -To change the value that the mutable reference refers to, we again use the `*` dereference operator to get to the value in `n_ref` before we can use the `+=` operator. +To change the value that the mutable reference refers to, we again use the `*` dereference operator to get to the value in `i` before we can use the `+=` operator. {{#quiz ../quizzes/ch08-01-vec-sec1.toml}}