more clippy fixups

mostly indentation changes, view with `-w`

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-09-11 12:23:11 +02:00
parent 653b1ca10e
commit 44fed91e17
3 changed files with 25 additions and 34 deletions

View File

@ -51,8 +51,7 @@ pub fn wrap_text(initial_indent: &str, subsequent_indent: &str, text: &str, colu
}
pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> String {
let type_text = match schema {
match schema {
Schema::Null => String::from("<null>"), // should not happen
Schema::String(_) => String::from("<string>"),
Schema::Boolean(_) => String::from("<boolean>"),
@ -66,9 +65,7 @@ pub fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> S
},
Schema::Object(_) => String::from("<object>"),
Schema::Array(_) => String::from("<array>"),
};
type_text
}
}
pub fn get_property_description(
@ -229,14 +226,14 @@ fn dump_api_return_schema(schema: &Schema) -> String {
fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> Option<String> {
match def {
MethodDefinition::None => return None,
MethodDefinition::None => None,
MethodDefinition::Simple(simple_method) => {
let param_descr = dump_api_parameters(&simple_method.parameters);
let return_descr = dump_api_return_schema(&simple_method.returns);
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
return Some(res);
Some(res)
}
MethodDefinition::Async(async_method) => {
let method = if method == "POST" { "UPLOAD" } else { method };
@ -247,7 +244,7 @@ fn dump_method_definition(method: &str, path: &str, def: &MethodDefinition) -> O
let return_descr = dump_api_return_schema(&async_method.returns);
let res = format!("**{} {}**\n\n{}\n\n{}", method, path, param_descr, return_descr);
return Some(res);
Some(res)
}
}
}

View File

@ -417,12 +417,10 @@ fn parse_property_string(value_str: &str, schema: &Schema) -> Result<Value, Erro
let kv: Vec<&str> = key_val.splitn(2, '=').collect();
if kv.len() == 2 {
param_list.push((kv[0].into(), kv[1].into()));
} else if let Some(key) = object_schema.default_key {
param_list.push((key.into(), kv[0].into()));
} else {
if let Some(key) = object_schema.default_key {
param_list.push((key.into(), kv[0].into()));
} else {
bail!("Value without key, but schema does not define a default key.");
}
bail!("Value without key, but schema does not define a default key.");
}
}
@ -511,24 +509,22 @@ pub fn parse_parameter_strings(data: &Vec<(String, String)>, schema: &ObjectSche
}
}
}
} else {
if additional_properties {
match params[key] {
Value::Null => {
params[key] = Value::String(value.to_owned());
},
Value::String(ref old) => {
params[key] = Value::Array(
vec![Value::String(old.to_owned()), Value::String(value.to_owned())]);
}
Value::Array(ref mut array) => {
array.push(Value::String(value.to_string()));
}
_ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)),
} else if additional_properties {
match params[key] {
Value::Null => {
params[key] = Value::String(value.to_owned());
},
Value::String(ref old) => {
params[key] = Value::Array(
vec![Value::String(old.to_owned()), Value::String(value.to_owned())]);
}
} else {
errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
Value::Array(ref mut array) => {
array.push(Value::String(value.to_string()));
}
_ => errors.push(format_err!("parameter '{}': expected array - type missmatch", key)),
}
} else {
errors.push(format_err!("parameter '{}': schema does not allow additional properties.", key));
}
}
@ -638,10 +634,8 @@ pub fn verify_json_object(data: &Value, schema: &ObjectSchema) -> Result<(), Err
}
_ => verify_json(value, prop_schema)?,
}
} else {
if !additional_properties {
bail!("property '{}': schema does not allow additional properties.", key);
}
} else if !additional_properties {
bail!("property '{}': schema does not allow additional properties.", key);
}
}

View File

@ -494,7 +494,7 @@ impl Drop for BackupReader {
impl BackupReader {
pub fn new(h2: H2Client, canceller: Canceller) -> Arc<Self> {
Arc::new(Self { h2, canceller: canceller })
Arc::new(Self { h2, canceller })
}
pub async fn get(