Merge pull request #3891 from rust-lang/revert-3501-main

Revert "Chapter 15-05: Fix incorrect interpretation of compiler error"
This commit is contained in:
Chris Krycho 2024-04-17 15:57:27 -06:00 committed by GitHub
commit d6adb1e276
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 4 deletions

View File

@ -191,10 +191,9 @@ However, theres one problem with this test, as shown here:
We cant modify the `MockMessenger` to keep track of the messages, because the
`send` method takes an immutable reference to `self`. We also cant take the
suggestion from the error text to use `&mut self` instead, because we are
testing an API and it's not a good idea to modify the API for the sole purpose
of testing. Usually, the test engineers do not have permission to modify the
API they're testing. Feel free to try and see what error message you get.
suggestion from the error text to use `&mut self` instead, because then the
signature of `send` wouldnt match the signature in the `Messenger` trait
definition (feel free to try and see what error message you get).
This is a situation in which interior mutability can help! Well store the
`sent_messages` within a `RefCell<T>`, and then the `send` method will be