ruma_api_macros: Simplify RequestField::as_* methods

This commit is contained in:
Jonas Platte 2019-11-16 15:55:54 +01:00
parent 772c378fe2
commit d0d1d97ee4
No known key found for this signature in database
GPG Key ID: 7D261D771D915378

View File

@ -350,29 +350,17 @@ impl RequestField {
/// Return the contained field if this request field is a body kind.
fn as_body_field(&self) -> Option<&Field> {
if let RequestField::Body(field) = self {
Some(field)
} else {
None
}
self.field_of_kind(RequestFieldKind::Body)
}
/// Return the contained field if this request field is a path kind.
fn as_path_field(&self) -> Option<&Field> {
if let RequestField::Path(field) = self {
Some(field)
} else {
None
}
self.field_of_kind(RequestFieldKind::Path)
}
/// Return the contained field if this request field is a query kind.
fn as_query_field(&self) -> Option<&Field> {
if let RequestField::Query(field) = self {
Some(field)
} else {
None
}
self.field_of_kind(RequestFieldKind::Query)
}
/// Gets the inner `Field` value.