mirror of
https://git.proxmox.com/git/proxmox
synced 2025-08-08 03:45:46 +00:00
clippy: collapse match/if let/..
best viewed with `-w` ;) Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
e303ad8605
commit
9c9b5c02b4
@ -41,10 +41,9 @@ fn get_property_completion(
|
|||||||
|
|
||||||
match schema {
|
match schema {
|
||||||
Schema::String(StringSchema {
|
Schema::String(StringSchema {
|
||||||
format: Some(format),
|
format: Some(ApiStringFormat::Enum(variants)),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if let ApiStringFormat::Enum(variants) = format {
|
|
||||||
let mut completions = Vec::new();
|
let mut completions = Vec::new();
|
||||||
for variant in variants.iter() {
|
for variant in variants.iter() {
|
||||||
if variant.value.starts_with(arg) {
|
if variant.value.starts_with(arg) {
|
||||||
@ -53,7 +52,6 @@ fn get_property_completion(
|
|||||||
}
|
}
|
||||||
return completions;
|
return completions;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Schema::Boolean(BooleanSchema { .. }) => {
|
Schema::Boolean(BooleanSchema { .. }) => {
|
||||||
let mut completions = Vec::new();
|
let mut completions = Vec::new();
|
||||||
let mut lowercase_arg = arg.to_string();
|
let mut lowercase_arg = arg.to_string();
|
||||||
|
@ -27,8 +27,7 @@ pub fn complete_file_name(arg: &str, _param: &HashMap<String, String>) -> Vec<St
|
|||||||
Err(_) => return result,
|
Err(_) => return result,
|
||||||
};
|
};
|
||||||
|
|
||||||
for item in dir.iter() {
|
for entry in dir.iter().flatten() {
|
||||||
if let Ok(entry) = item {
|
|
||||||
if let Ok(name) = entry.file_name().to_str() {
|
if let Ok(name) = entry.file_name().to_str() {
|
||||||
if name == "." || name == ".." {
|
if name == "." || name == ".." {
|
||||||
continue;
|
continue;
|
||||||
@ -51,7 +50,6 @@ pub fn complete_file_name(arg: &str, _param: &HashMap<String, String>) -> Vec<St
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -74,15 +74,13 @@ pub(crate) fn parse_argument_list<T: AsRef<str>>(
|
|||||||
None => {
|
None => {
|
||||||
let mut want_bool = false;
|
let mut want_bool = false;
|
||||||
let mut can_default = false;
|
let mut can_default = false;
|
||||||
if let Some((_optional, param_schema)) = schema.lookup(&name) {
|
if let Some((_optional, Schema::Boolean(boolean_schema))) = schema.lookup(&name) {
|
||||||
if let Schema::Boolean(boolean_schema) = param_schema {
|
|
||||||
want_bool = true;
|
want_bool = true;
|
||||||
match boolean_schema.default {
|
match boolean_schema.default {
|
||||||
Some(false) | None => can_default = true,
|
Some(false) | None => can_default = true,
|
||||||
Some(true) => (),
|
Some(true) => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut next_is_argument = false;
|
let mut next_is_argument = false;
|
||||||
let mut next_is_bool = false;
|
let mut next_is_bool = false;
|
||||||
|
@ -126,11 +126,10 @@ pub fn dump_properties(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if style == ParameterDisplayStyle::Config {
|
if style == ParameterDisplayStyle::Config {
|
||||||
match schema {
|
if let Schema::String(StringSchema {
|
||||||
Schema::String(StringSchema {
|
|
||||||
format: Some(ApiStringFormat::PropertyString(sub_schema)),
|
format: Some(ApiStringFormat::PropertyString(sub_schema)),
|
||||||
..
|
..
|
||||||
}) => {
|
}) = schema {
|
||||||
match sub_schema {
|
match sub_schema {
|
||||||
Schema::Object(object_schema) => {
|
Schema::Object(object_schema) => {
|
||||||
let sub_text = dump_properties(
|
let sub_text = dump_properties(
|
||||||
@ -147,8 +146,6 @@ pub fn dump_properties(
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => { /* do nothing */ }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if *optional {
|
if *optional {
|
||||||
optional_list.push(param_descr);
|
optional_list.push(param_descr);
|
||||||
|
@ -463,13 +463,11 @@ impl SectionConfig {
|
|||||||
} else {
|
} else {
|
||||||
config[key].as_array_mut().unwrap().push(value);
|
config[key].as_array_mut().unwrap().push(value);
|
||||||
}
|
}
|
||||||
} else {
|
} else if config[&key] == Value::Null {
|
||||||
if config[&key] == Value::Null {
|
|
||||||
config[key] = value;
|
config[key] = value;
|
||||||
} else {
|
} else {
|
||||||
bail!("duplicate property '{}'", key);
|
bail!("duplicate property '{}'", key);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bail!("syntax error (expected section properties)");
|
bail!("syntax error (expected section properties)");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user