-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Remove pointless calls to *iter() and iter_mut() #26190
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,7 @@ | |
//! gadget_owner.gadgets.borrow_mut().push(gadget2.clone().downgrade()); | ||
//! | ||
//! // Iterate over our Gadgets, printing their details out | ||
//! for gadget_opt in gadget_owner.gadgets.borrow().iter() { | ||
//! for gadget_opt in &*gadget_owner.gadgets.borrow() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not strictly sure that doing a reborrow is clearer than calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @steveklabnik that the |
||
//! | ||
//! // gadget_opt is a Weak<Gadget>. Since weak pointers can't guarantee | ||
//! // that their object is still allocated, we need to call upgrade() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of thing is extra interesting, because this looks like a change in semantics, but since
err_map
is a reference, it's not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, this isn't particularly worrisome because the default - move if it's a value or take references if it's a reference - is always either the right thing or a compiler error. YMMV.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't think it's a problem at all, just an interesting side-effect of looking at the diff.