diff --git a/quizzes/ch10-04-inventory.toml b/quizzes/ch10-04-inventory.toml index 13eb57243e..5ad8a1d62c 100644 --- a/quizzes/ch10-04-inventory.toml +++ b/quizzes/ch10-04-inventory.toml @@ -292,7 +292,9 @@ println!("{:?}", result.scores); context = """ This program is actually safe as written. It is a limitation of the borrow checker to not understand that `get_curve` only borrows `curve`, and doesn't affect `scores`. However, in theory if `get_curve` were changed to return a reference -to something with `self.scores`, then memory safety could potentially be violated. +to something with `self.scores`, then memory safety could potentially be violated. Note that +the `let x = &result.scores[0];` program would not compile, as Rust's borrow checker would not +allow to borrow `result` as mutable while immutable borrow of `result` exists. """ [[questions]] @@ -383,4 +385,4 @@ so it allows the function to compile. This is a common workaround for this type Another option is to leverage the fact that `self.curve` is cheap to copy and use [`Option::copied`](https://doc.rust-lang.org/std/option/enum.Option.html#method.copied), which would release the borrow on `self` as soon as `.copied()` is called. -""" \ No newline at end of file +"""