What it does
For the following case:
if let Some(legacy_path) = legacy_bin_path(package_root, &bin.name(), has_lib) {
warnings.push(format!(
"path `{}` was erroneously implicitly accepted for binary `{}`,\n\
please set bin.path in Cargo.toml",
legacy_path.display(),
bin.name()
));
Some(legacy_path)
} else {
None
}
It is better to use Option::inspect.
Advantage
Drawbacks
Cannot think of so far.
Example
if let Some(legacy_path) = legacy_bin_path(package_root, &bin.name(), has_lib) {
warnings.push(format!(
"path `{}` was erroneously implicitly accepted for binary `{}`,\n\
please set bin.path in Cargo.toml",
legacy_path.display(),
bin.name()
));
Some(legacy_path)
} else {
None
}
Could be written as:
legacy_bin_path(package_root, &bin.name(), has_lib)
.inspect(|legacy_path| {
warnings.push(format!(
"path `{}` was erroneously implicitly accepted for binary `{}`,\n\
please set bin.path in Cargo.toml",
legacy_path.display(),
bin.name()
));
})
Comparison with existing lints
The given example will be covered by clippy::manual_map if #16775 is merged, but using Option::inspect would be better.
Additional Context
One real world example: https://docs.rs/cargo/0.64.0/src/cargo/util/toml/targets.rs.html#325
What it does
For the following case:
It is better to use
Option::inspect.Advantage
Drawbacks
Cannot think of so far.
Example
Could be written as:
Comparison with existing lints
The given example will be covered by
clippy::manual_mapif #16775 is merged, but usingOption::inspectwould be better.Additional Context
One real world example: https://docs.rs/cargo/0.64.0/src/cargo/util/toml/targets.rs.html#325