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
Not only the type changes from T to Option<T>, but that makes fallible code infallible: if for any reason this part of code is given an bogusly empty Vec or VecDeque, it will continue executing instead of panicking which may not be a good idea.
A more similar substitution would be to use vec.pop().unwrap() for example, but isn't that a bit heavy?
What it does
Detect uses of
Vec::remove
orVecDeque::remove
whenVec::pop
,VecDeque::pop_front
orVecDeque::pop_back
could have been usedAdvantage
Drawbacks
Vec::remove
it would break code because it changes the return type fromT
toOption<T>
Example
Could be written as:
The text was updated successfully, but these errors were encountered: