MCPcopy Create free account
hub / github.com/csskit/csskit / has_derive_of

Function has_derive_of

crates/csskit_proc_macro/src/syntax.rs:9–26  ·  view source on GitHub ↗
(attrs: &[Attribute], name: &'static str)

Source from the content-addressed store, hash-verified

7use css_value_definition_parser::*;
8
9fn has_derive_of(attrs: &[Attribute], name: &'static str) -> bool {
10 for attr in attrs {
11 if attr.path().is_ident("derive") {
12 let nested = attr.parse_args_with(Punctuated::<Meta, Token![,]>::parse_terminated).unwrap_or_default();
13 for meta in nested {
14 match meta {
15 Meta::Path(path)
16 if path.is_ident(name) || path.segments.last().map(|s| s.ident == name).unwrap_or(false) =>
17 {
18 return true;
19 }
20 _ => {}
21 }
22 }
23 }
24 }
25 false
26}
27
28pub fn generate(defs: Def, ast: DeriveInput) -> TokenStream {
29 let has_a_lifetime = ast.generics.lifetimes().any(|l| l.lifetime.ident == "a");

Callers 1

generateFunction · 0.85

Calls 1

pathMethod · 0.80

Tested by

no test coverage detected