Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 15-05: Incorrect interpretation of compiler error #3500

Closed
kingh0730 opened this issue Jan 7, 2023 · 1 comment
Closed

Chapter 15-05: Incorrect interpretation of compiler error #3500

kingh0730 opened this issue Jan 7, 2023 · 1 comment

Comments

@kingh0730
Copy link
Contributor

kingh0730 commented Jan 7, 2023

URL to the section(s) of the book with this problem: https://doc.rust-lang.org/book/ch15-05-interior-mutability.html#a-use-case-for-interior-mutability-mock-objects

Description of the problem:

The following sentence is incorrect:

We also can’t take the suggestion from the error text to use &mut self instead, because then the signature of send wouldn’t match the signature in the Messenger trait definition

because the suggestion of the compiler is to modify Line 2, the signature in the Messenger trait definition itself, NOT Line 57 which is the implementation of send in MockMessenger.

Suggested fix:

We also can't 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.

@chriskrycho
Copy link
Contributor

As noted on the PR, the original text is fine here, actually. In particular, the reasons given by the book are accurate, and in this case the text assumes the person implementing the code is also testing it—nothing to do with test engineers!

@chriskrycho chriskrycho closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants