ruma_api_macros: Simplify RequestField::as_* methods
This commit is contained in:
parent
772c378fe2
commit
d0d1d97ee4
@ -350,29 +350,17 @@ impl RequestField {
|
|||||||
|
|
||||||
/// Return the contained field if this request field is a body kind.
|
/// Return the contained field if this request field is a body kind.
|
||||||
fn as_body_field(&self) -> Option<&Field> {
|
fn as_body_field(&self) -> Option<&Field> {
|
||||||
if let RequestField::Body(field) = self {
|
self.field_of_kind(RequestFieldKind::Body)
|
||||||
Some(field)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the contained field if this request field is a path kind.
|
/// Return the contained field if this request field is a path kind.
|
||||||
fn as_path_field(&self) -> Option<&Field> {
|
fn as_path_field(&self) -> Option<&Field> {
|
||||||
if let RequestField::Path(field) = self {
|
self.field_of_kind(RequestFieldKind::Path)
|
||||||
Some(field)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the contained field if this request field is a query kind.
|
/// Return the contained field if this request field is a query kind.
|
||||||
fn as_query_field(&self) -> Option<&Field> {
|
fn as_query_field(&self) -> Option<&Field> {
|
||||||
if let RequestField::Query(field) = self {
|
self.field_of_kind(RequestFieldKind::Query)
|
||||||
Some(field)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the inner `Field` value.
|
/// Gets the inner `Field` value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user