Skip to content

Commit 6cc1bb8

Browse files
authored
Merge pull request #4142 from rust-lang/improved-error-message
Ch. 15.5: account for improved error message
2 parents 139538d + d8f0f5b commit 6cc1bb8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ch15-05-interior-mutability.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,10 @@ However, there’s one problem with this test, as shown here:
189189

190190
We can’t modify the `MockMessenger` to keep track of the messages, because the
191191
`send` method takes an immutable reference to `self`. We also can’t take the
192-
suggestion from the error text to use `&mut self` instead, because then the
193-
signature of `send` wouldn’t match the signature in the `Messenger` trait
194-
definition (feel free to try and see what error message you get).
192+
suggestion from the error text to use `&mut self` in both the `impl` method and
193+
the `trait` definition. We do not want to change the `Messenger` trait solely
194+
for the sake of testing. Instead, we need to find a way to make our test code
195+
work correctly with our existing design.
195196

196197
This is a situation in which interior mutability can help! We’ll store the
197198
`sent_messages` within a `RefCell<T>`, and then the `send` method will be

0 commit comments

Comments
 (0)