clippy: collapse match/if let/..

best viewed with `-w` ;)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2021-12-02 09:01:52 +01:00
parent e303ad8605
commit 9c9b5c02b4
5 changed files with 49 additions and 60 deletions

View File

@ -41,10 +41,9 @@ fn get_property_completion(
match schema {
Schema::String(StringSchema {
format: Some(format),
format: Some(ApiStringFormat::Enum(variants)),
..
}) => {
if let ApiStringFormat::Enum(variants) = format {
let mut completions = Vec::new();
for variant in variants.iter() {
if variant.value.starts_with(arg) {
@ -53,7 +52,6 @@ fn get_property_completion(
}
return completions;
}
}
Schema::Boolean(BooleanSchema { .. }) => {
let mut completions = Vec::new();
let mut lowercase_arg = arg.to_string();

View File

@ -27,8 +27,7 @@ pub fn complete_file_name(arg: &str, _param: &HashMap<String, String>) -> Vec<St
Err(_) => return result,
};
for item in dir.iter() {
if let Ok(entry) = item {
for entry in dir.iter().flatten() {
if let Ok(name) = entry.file_name().to_str() {
if name == "." || name == ".." {
continue;
@ -51,7 +50,6 @@ pub fn complete_file_name(arg: &str, _param: &HashMap<String, String>) -> Vec<St
}
}
}
}
result
}

View File

@ -74,15 +74,13 @@ pub(crate) fn parse_argument_list<T: AsRef<str>>(
None => {
let mut want_bool = false;
let mut can_default = false;
if let Some((_optional, param_schema)) = schema.lookup(&name) {
if let Schema::Boolean(boolean_schema) = param_schema {
if let Some((_optional, Schema::Boolean(boolean_schema))) = schema.lookup(&name) {
want_bool = true;
match boolean_schema.default {
Some(false) | None => can_default = true,
Some(true) => (),
}
}
}
let mut next_is_argument = false;
let mut next_is_bool = false;

View File

@ -126,11 +126,10 @@ pub fn dump_properties(
}
if style == ParameterDisplayStyle::Config {
match schema {
Schema::String(StringSchema {
if let Schema::String(StringSchema {
format: Some(ApiStringFormat::PropertyString(sub_schema)),
..
}) => {
}) = schema {
match sub_schema {
Schema::Object(object_schema) => {
let sub_text = dump_properties(
@ -147,8 +146,6 @@ pub fn dump_properties(
_ => unreachable!(),
}
}
_ => { /* do nothing */ }
}
}
if *optional {
optional_list.push(param_descr);

View File

@ -463,13 +463,11 @@ impl SectionConfig {
} else {
config[key].as_array_mut().unwrap().push(value);
}
} else {
if config[&key] == Value::Null {
} else if config[&key] == Value::Null {
config[key] = value;
} else {
bail!("duplicate property '{}'", key);
}
}
} else {
bail!("syntax error (expected section properties)");
}