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,18 +41,16 @@ 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) {
|
||||
completions.push(variant.value.to_string());
|
||||
}
|
||||
let mut completions = Vec::new();
|
||||
for variant in variants.iter() {
|
||||
if variant.value.starts_with(arg) {
|
||||
completions.push(variant.value.to_string());
|
||||
}
|
||||
return completions;
|
||||
}
|
||||
return completions;
|
||||
}
|
||||
Schema::Boolean(BooleanSchema { .. }) => {
|
||||
let mut completions = Vec::new();
|
||||
|
@ -27,28 +27,26 @@ 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 {
|
||||
if let Ok(name) = entry.file_name().to_str() {
|
||||
if name == "." || name == ".." {
|
||||
for entry in dir.iter().flatten() {
|
||||
if let Ok(name) = entry.file_name().to_str() {
|
||||
if name == "." || name == ".." {
|
||||
continue;
|
||||
}
|
||||
let mut newpath = dirname.clone();
|
||||
newpath.push(name);
|
||||
|
||||
if let Ok(stat) = fstatat(libc::AT_FDCWD, &newpath, AtFlags::empty())
|
||||
{
|
||||
if (stat.st_mode & libc::S_IFMT) == libc::S_IFDIR {
|
||||
newpath.push("");
|
||||
if let Some(newpath) = newpath.to_str() {
|
||||
result.push(newpath.to_owned());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let mut newpath = dirname.clone();
|
||||
newpath.push(name);
|
||||
|
||||
if let Ok(stat) = fstatat(libc::AT_FDCWD, &newpath, AtFlags::empty())
|
||||
{
|
||||
if (stat.st_mode & libc::S_IFMT) == libc::S_IFDIR {
|
||||
newpath.push("");
|
||||
if let Some(newpath) = newpath.to_str() {
|
||||
result.push(newpath.to_owned());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some(newpath) = newpath.to_str() {
|
||||
result.push(newpath.to_owned());
|
||||
}
|
||||
}
|
||||
if let Some(newpath) = newpath.to_str() {
|
||||
result.push(newpath.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,13 +74,11 @@ 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 {
|
||||
want_bool = true;
|
||||
match boolean_schema.default {
|
||||
Some(false) | None => can_default = true,
|
||||
Some(true) => (),
|
||||
}
|
||||
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) => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,28 +126,25 @@ pub fn dump_properties(
|
||||
}
|
||||
|
||||
if style == ParameterDisplayStyle::Config {
|
||||
match schema {
|
||||
Schema::String(StringSchema {
|
||||
format: Some(ApiStringFormat::PropertyString(sub_schema)),
|
||||
..
|
||||
}) => {
|
||||
match sub_schema {
|
||||
Schema::Object(object_schema) => {
|
||||
let sub_text = dump_properties(
|
||||
object_schema,
|
||||
&next_indent,
|
||||
ParameterDisplayStyle::ConfigSub,
|
||||
&[],
|
||||
);
|
||||
param_descr.push_str(&sub_text);
|
||||
}
|
||||
Schema::Array(_) => {
|
||||
// do nothing - description should explain the list type
|
||||
}
|
||||
_ => unreachable!(),
|
||||
if let Schema::String(StringSchema {
|
||||
format: Some(ApiStringFormat::PropertyString(sub_schema)),
|
||||
..
|
||||
}) = schema {
|
||||
match sub_schema {
|
||||
Schema::Object(object_schema) => {
|
||||
let sub_text = dump_properties(
|
||||
object_schema,
|
||||
&next_indent,
|
||||
ParameterDisplayStyle::ConfigSub,
|
||||
&[],
|
||||
);
|
||||
param_descr.push_str(&sub_text);
|
||||
}
|
||||
Schema::Array(_) => {
|
||||
// do nothing - description should explain the list type
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
_ => { /* do nothing */ }
|
||||
}
|
||||
}
|
||||
if *optional {
|
||||
|
@ -463,12 +463,10 @@ impl SectionConfig {
|
||||
} else {
|
||||
config[key].as_array_mut().unwrap().push(value);
|
||||
}
|
||||
} else if config[&key] == Value::Null {
|
||||
config[key] = value;
|
||||
} else {
|
||||
if config[&key] == Value::Null {
|
||||
config[key] = value;
|
||||
} else {
|
||||
bail!("duplicate property '{}'", key);
|
||||
}
|
||||
bail!("duplicate property '{}'", key);
|
||||
}
|
||||
} else {
|
||||
bail!("syntax error (expected section properties)");
|
||||
|
Loading…
Reference in New Issue
Block a user