fix(lint): apply clippy suggestions

This commit is contained in:
Orhun Parmaksız 2021-12-13 01:54:28 +03:00
parent aa78731b3f
commit c98e427d2c
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
2 changed files with 6 additions and 6 deletions

View file

@ -46,12 +46,12 @@ impl Sysctl {
let parameter = self
.parameters
.iter_mut()
.find(|param| param.name == *param_name.replace("/", "."));
.find(|param| param.name == *param_name.replace('/', "."));
if parameter.is_none() && !self.config.ignore_errors {
eprintln!(
"{}: cannot stat /proc/{}: No such file or directory",
env!("CARGO_PKG_NAME").split('-').collect::<Vec<_>>()[0],
param_name.replace(".", "/")
param_name.replace('.', "/")
)
}
parameter
@ -63,16 +63,16 @@ impl Sysctl {
.parameters
.iter()
.filter(|param| {
param.name == query.replace("/", ".")
param.name == query.replace('/', ".")
|| param.section.to_string() == query
|| param.absolute_name() == Some(&query.replace("/", "."))
|| param.absolute_name() == Some(&query.replace('/', "."))
})
.collect::<Vec<&Parameter>>();
if parameters.is_empty() {
eprintln!(
"{}: cannot stat /proc/{}: No such file or directory",
env!("CARGO_PKG_NAME").split('-').collect::<Vec<_>>()[0],
query.replace(".", "/")
query.replace('.', "/")
)
}
parameters

View file

@ -37,7 +37,7 @@ impl From<String> for Section {
impl<'a> From<&'a Path> for Section {
fn from(value: &'a Path) -> Self {
for section in Self::variants() {
if value.file_stem().map(|v| v.to_str()).flatten() == Some(&section.to_string()) {
if value.file_stem().and_then(|v| v.to_str()) == Some(&section.to_string()) {
return *section;
}
}