-
Notifications
You must be signed in to change notification settings - Fork 113
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 2 Closure Example won't compile #27
Comments
I agree, and actually decided that was the best way even before I read all the way. (I get embarrassed about compile failures in published work and fix them quickly). Mutable borrowing is a strict business! Thanks for the keen eye. The general solution I have is that I must always use |
And Thanks again for this great material. |
Well, you were fast. I'm closing this unless you object. |
Thank you for this project. Has helped me a ton!
File
2-structs-enums-lifetimes.md
Example
Won't compile. Compiler yells
set
must be mutable, then it complains about the assertion becauseanswer
is currently mutably borrowed by the closure.One Solution
Using the extra scope might throw beginners off a little... But at least they'll know there is more to closures (lifetimes and scopes).
The text was updated successfully, but these errors were encountered: