diff --git a/ruma-api-macros/src/api.rs b/ruma-api-macros/src/api.rs index 9ddb4b12..80cdf2b4 100644 --- a/ruma-api-macros/src/api.rs +++ b/ruma-api-macros/src/api.rs @@ -20,9 +20,7 @@ use self::{metadata::Metadata, request::Request, response::Response}; /// Removes `serde` attributes from struct fields. pub fn strip_serde_attrs(field: &Field) -> Field { let mut field = field.clone(); - field - .attrs - .retain(|attr| attr.path.segments.len() != 1 || attr.path.segments[0].ident != "serde"); + field.attrs.retain(|attr| attr.path.is_ident("serde")); field } diff --git a/ruma-api-macros/src/api/attribute.rs b/ruma-api-macros/src/api/attribute.rs index ffedffdd..d958ac13 100644 --- a/ruma-api-macros/src/api/attribute.rs +++ b/ruma-api-macros/src/api/attribute.rs @@ -29,13 +29,10 @@ impl Meta { /// /// Panics if the given attribute is a ruma_api attribute, but fails to parse. pub fn from_attribute(attr: &syn::Attribute) -> syn::Result> { - match &attr.path { - syn::Path { leading_colon: None, segments } - if segments.len() == 1 && segments[0].ident == "ruma_api" => - { - attr.parse_args().map(Some) - } - _ => Ok(None), + if attr.path.is_ident("ruma_api") { + attr.parse_args().map(Some) + } else { + Ok(None) } } }