ruma-api-macros: Use syn::Path::is_ident
This commit is contained in:
parent
f0e724d391
commit
8c898f3766
@ -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
|
||||
}
|
||||
|
||||
|
@ -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<Option<Self>> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user