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
Here the diagnostic suggests to add as_ref as such:
note: this function takes ownership of the receiver `self`, which moves `*ptr`
help: consider calling `.as_ref()` to borrow the type's contents
|
8 | ptr.as_ref().unwrap().val += 1;
| +++++++++
This suggestion is incorrect – as_ref will never (AFAIK) produce a mutable reference necessary for the assignment. We should suggest as_mut where we know that a mutable reference will be required, instead.