ruma_api_macros: Use find_map in Request::newtype_body_field
This commit is contained in:
parent
d0d1d97ee4
commit
2261067251
@ -72,16 +72,9 @@ impl Request {
|
|||||||
|
|
||||||
/// Returns the body field.
|
/// Returns the body field.
|
||||||
pub fn newtype_body_field(&self) -> Option<&Field> {
|
pub fn newtype_body_field(&self) -> Option<&Field> {
|
||||||
for request_field in self.fields.iter() {
|
self.fields
|
||||||
match *request_field {
|
.iter()
|
||||||
RequestField::NewtypeBody(ref field) => {
|
.find_map(RequestField::as_newtype_body_field)
|
||||||
return Some(field);
|
|
||||||
}
|
|
||||||
_ => continue,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Produces code for a struct initializer for body fields on a variable named `request`.
|
/// Produces code for a struct initializer for body fields on a variable named `request`.
|
||||||
@ -353,6 +346,11 @@ impl RequestField {
|
|||||||
self.field_of_kind(RequestFieldKind::Body)
|
self.field_of_kind(RequestFieldKind::Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the contained field if this request field is a body kind.
|
||||||
|
fn as_newtype_body_field(&self) -> Option<&Field> {
|
||||||
|
self.field_of_kind(RequestFieldKind::NewtypeBody)
|
||||||
|
}
|
||||||
|
|
||||||
/// 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> {
|
||||||
self.field_of_kind(RequestFieldKind::Path)
|
self.field_of_kind(RequestFieldKind::Path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user