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

View File

@ -38,16 +38,13 @@ 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>"),
Schema::Array(_) => String::from("<array>"),
};