Cleanup of if statement with unwraps by a more compact match statement

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-03-20 09:28:14 +01:00 committed by Dietmar Maurer
parent 8346f0d59b
commit e04d1bfadc
1 changed files with 7 additions and 10 deletions

View File

@ -38,14 +38,11 @@ fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> Strin
Schema::String(_) => String::from("<string>"),
Schema::Boolean(_) => String::from("<boolean>"),
Schema::Integer(integer_schema) => {
if integer_schema.minimum != None && integer_schema.maximum != None {
format!("<integer> ({} - {})", integer_schema.minimum.unwrap(), integer_schema.maximum.unwrap())
} else if integer_schema.minimum != None {
format!("<integer> ({} - N)", integer_schema.minimum.unwrap())
} else if integer_schema.maximum != None {
format!("<integer> (-N - {})", integer_schema.maximum.unwrap())
} else {
String::from("<integer>")
match (integer_schema.minimum, integer_schema.maximum) {
(Some(min), Some(max)) => format!("<integer> ({} - {})", min, max),
(Some(min), None) => format!("<integer> ({} - N)", min),
(None, Some(max)) => format!("<integer> (-N - {})", max),
_ => String::from("<integer>"),
}
},
Schema::Object(_) => String::from("<object>"),