Add a lint for Option::take
on a temporary
#8618
Labels
A-lint
Area: New lints
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
L-complexity
Lint: Belongs in the complexity lint group
What it does
(Inspired by Take() vs as_ref().take() on URLO.)
Lint when calling
Option::take
on a temporary, as when you have an owned temporary there's no need totake
it -- you already have ownership, and you won't be able to see theNone
left behind, so thetake
can just be omitted.Lint Name
option_take_on_temporary
Category
suspicious, complexity
Advantage
Drawbacks
None, so long as the temporary detection is accurate.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: