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.
|
/// Removes `serde` attributes from struct fields.
|
||||||
pub fn strip_serde_attrs(field: &Field) -> Field {
|
pub fn strip_serde_attrs(field: &Field) -> Field {
|
||||||
let mut field = field.clone();
|
let mut field = field.clone();
|
||||||
field
|
field.attrs.retain(|attr| attr.path.is_ident("serde"));
|
||||||
.attrs
|
|
||||||
.retain(|attr| attr.path.segments.len() != 1 || attr.path.segments[0].ident != "serde");
|
|
||||||
field
|
field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,13 +29,10 @@ impl Meta {
|
|||||||
///
|
///
|
||||||
/// Panics if the given attribute is a ruma_api attribute, but fails to parse.
|
/// 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>> {
|
pub fn from_attribute(attr: &syn::Attribute) -> syn::Result<Option<Self>> {
|
||||||
match &attr.path {
|
if attr.path.is_ident("ruma_api") {
|
||||||
syn::Path { leading_colon: None, segments }
|
attr.parse_args().map(Some)
|
||||||
if segments.len() == 1 && segments[0].ident == "ruma_api" =>
|
} else {
|
||||||
{
|
Ok(None)
|
||||||
attr.parse_args().map(Some)
|
|
||||||
}
|
|
||||||
_ => Ok(None),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user