You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Composite types such as structs, tuples, and enums are always captured entirely, not by individual fields. It may be necessary to borrow into a local variable in order to capture a single field:
If, instead, the closure were to use self.vec directly, then it would attempt to capture self by mutable reference. But since self.set is already borrowed to iterate over, the code would not compile.
The text was updated successfully, but these errors were encountered:
Prashant-Shekhar-Rao
changed the title
https://doc.rust-lang.org/reference/types/closure.html is not accurate
types/closure is not accurate. We don't need to use a new variable when capturing a field from a struct
Oct 2, 2023
This means that this code should not compile.
But this code compiles perfectly.
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e739bcc43dc34f40ef07235f06c69f63
The text was updated successfully, but these errors were encountered: