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
fwiw, I tend to disagree with the rationale of such lint. If the mutation happens to bring the object into the asserted state, it's perfectly reasonable to mutate inside an assert. Consider
// Content-Policy processing for this request already done, don't forward itassert!(headers.remove('X-Content-Policy').is_some())
Here, we remove an entry from the map, assert that the entry has actually been there before, and continue using that map. The advantages as stated above are actually reversed: We clearly state that we rely on the side-effect of the mutation (removal + check that the value was there before).
What it does
Checks for methods that take
&mut
arguments inside ofassert
(orassert_eq
) etc statements.The mutation should be done first, and then the result should be checked.
This is probably a "suspicious" lint.
Advantage
Drawbacks
Your code will be slightly more verbose.
Example
Before:
After:
In the real world: bevyengine/bevy@4fbdc97
The text was updated successfully, but these errors were encountered: