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,16 +38,13 @@ fn get_schema_type_text(schema: &Schema, _style: ParameterDisplayStyle) -> Strin
Schema::String(_) => String::from("<string>"), Schema::String(_) => String::from("<string>"),
Schema::Boolean(_) => String::from("<boolean>"), Schema::Boolean(_) => String::from("<boolean>"),
Schema::Integer(integer_schema) => { Schema::Integer(integer_schema) => {
if integer_schema.minimum != None && integer_schema.maximum != None { match (integer_schema.minimum, integer_schema.maximum) {
format!("<integer> ({} - {})", integer_schema.minimum.unwrap(), integer_schema.maximum.unwrap()) (Some(min), Some(max)) => format!("<integer> ({} - {})", min, max),
} else if integer_schema.minimum != None { (Some(min), None) => format!("<integer> ({} - N)", min),
format!("<integer> ({} - N)", integer_schema.minimum.unwrap()) (None, Some(max)) => format!("<integer> (-N - {})", max),
} else if integer_schema.maximum != None { _ => String::from("<integer>"),
format!("<integer> (-N - {})", integer_schema.maximum.unwrap()) }
} else { },
String::from("<integer>")
}
},
Schema::Object(_) => String::from("<object>"), Schema::Object(_) => String::from("<object>"),
Schema::Array(_) => String::from("<array>"), Schema::Array(_) => String::from("<array>"),
}; };