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
I stumbled upon cases when developers are not familiar enough with all the functions that come with standard libs, such as Option::filter(). Instead, they program that functionality each time, which makes the code much more complex, error prone, and less readable.
Lint Name
filter
Category
style, complexity
Advantage
Reduces complexity substantially.
Improves code readability.
Makes use of lib function instead of coding its functionality in each usage.
Drawbacks
None that I can think of.
Example
match s {None => None,Some(x) => {if x.is_empty(){None}else{Some(x)}}}
What it does
I stumbled upon cases when developers are not familiar enough with all the functions that come with standard libs, such as
Option::filter()
. Instead, they program that functionality each time, which makes the code much more complex, error prone, and less readable.Lint Name
filter
Category
style, complexity
Advantage
Drawbacks
None that I can think of.
Example
Could be written as:
Full example:
The text was updated successfully, but these errors were encountered: