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.
|
||||
pub fn newtype_body_field(&self) -> Option<&Field> {
|
||||
for request_field in self.fields.iter() {
|
||||
match *request_field {
|
||||
RequestField::NewtypeBody(ref field) => {
|
||||
return Some(field);
|
||||
}
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
self.fields
|
||||
.iter()
|
||||
.find_map(RequestField::as_newtype_body_field)
|
||||
}
|
||||
|
||||
/// 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)
|
||||
}
|
||||
|
||||
/// 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.
|
||||
fn as_path_field(&self) -> Option<&Field> {
|
||||
self.field_of_kind(RequestFieldKind::Path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user