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

Function extract_atom

crates/csskit_derives/src/attributes.rs:73–81  ·  view source on GitHub ↗
(attrs: &[Attribute])

Source from the content-addressed store, hash-verified

71}
72
73pub fn extract_atom(attrs: &[Attribute]) -> Result<Option<Atom>> {
74 let Some(attr) = attrs.iter().find(|a| a.path().is_ident("atom")) else {
75 return Ok(None);
76 };
77 match &attr.meta {
78 Meta::List(meta) => Ok(Some(Atom(meta.parse_args::<ExprPath>()?))),
79 _ => Err(Error::new_spanned(&attr.meta, "#[atom] requires a path argument, e.g. #[atom(MyAtomSet::my_atom)]")),
80 }
81}

Callers 3

from_fieldsMethod · 0.85
newMethod · 0.85
deriveFunction · 0.85

Calls 4

ErrClass · 0.85
iterMethod · 0.80
pathMethod · 0.80
AtomClass · 0.70

Tested by

no test coverage detected