pub enum ExpandedAttr {
Direct(Attribute),
Nested {
attr: Meta,
condition: TokenStream,
original: Box<Attribute>,
},
}Expand description
Represents an attribute that might have been extracted from a #[cfg_attr(...)]
Variants§
Direct(Attribute)
A standard attribute like #[foo(...)]
Nested
An attribute found inside cfg_attr(condition, ...)
attr is the parsed Meta of the inner attribute (since it lacks #[...] braces in the stream)
condition is the cfg condition that guarded it.
Implementations§
Source§impl ExpandedAttr
impl ExpandedAttr
Sourcepub fn parse_args<T: Parse>(&self) -> Result<T>
pub fn parse_args<T: Parse>(&self) -> Result<T>
Examples found in repository?
examples/usage.rs (line 31)
19fn parse_field(field: &Field) {
20 println!("Processing field attributes...");
21
22 // Automatically looks inside cfg_attr and handles nesting
23 let koruma_attrs = field.attrs.find_attribute("koruma");
24
25 if koruma_attrs.is_empty() {
26 println!("No koruma attributes found.");
27 return;
28 }
29
30 for expanded in koruma_attrs {
31 match expanded.parse_args::<KorumaAttr>() {
32 Ok(attr) => {
33 println!("Found koruma attribute: {}", attr.name);
34 if let ExpandedAttr::Nested { condition, .. } = &expanded {
35 println!(" - Condition: {}", condition);
36 }
37 },
38 Err(e) => println!(" - Error parsing args: {}", e),
39 }
40 }
41}pub fn path(&self) -> &Path
pub fn is_ident(&self, ident: &str) -> bool
Trait Implementations§
Source§impl Clone for ExpandedAttr
impl Clone for ExpandedAttr
Source§fn clone(&self) -> ExpandedAttr
fn clone(&self) -> ExpandedAttr
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ExpandedAttr
impl RefUnwindSafe for ExpandedAttr
impl !Send for ExpandedAttr
impl !Sync for ExpandedAttr
impl Unpin for ExpandedAttr
impl UnwindSafe for ExpandedAttr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more