Closed
Description
What it does
This lint replaces the introduction of a simple closure with the named function that is being used in said closure.
Lint Name
replace_mapped_closure_with_into
Category
complexity
Advantage
- Reduces complexity of the
map
by introducing a common function name instead of a closure + identifier
Drawbacks
- May be less readable for newcomers.
- No performance drawback.
Example
impl IpResource {
pub fn mac_address(&self) -> Option<MacAddr6> {
self.mac_address.map(|x| x.into())
}
}
Could be written as:
impl IpResource {
pub fn mac_address(&self) -> Option<MacAddr6> {
self.mac_address.map(Into::into)
}
}