pub struct MacroAttribute { /* private fields */ }
Expand description
Represents a macro attribute and its arguments like:
#[attribute(key="value")]
Implementations§
Source§impl MacroAttribute
impl MacroAttribute
Sourcepub fn new(attribute: Attribute) -> Result<Self>
pub fn new(attribute: Attribute) -> Result<Self>
Constructs a new MacroAttribute
from an Attribute
.
Sourcepub fn from_attribute_args(
path: &str,
attribute_args: AttributeArgs,
style: AttrStyle,
) -> Self
pub fn from_attribute_args( path: &str, attribute_args: AttributeArgs, style: AttrStyle, ) -> Self
Constructs a MacroAttribute
from an AttributeArgs
.
Sourcepub fn path(&self) -> &str
pub fn path(&self) -> &str
Returns the path
of an attribute.
For #[attribute(name="value")]
the path is "attribute"
.
Sourcepub fn args(&self) -> &[MetaItem]
pub fn args(&self) -> &[MetaItem]
Returns the arguments of the attribute.
For #[attribute(name="value", number=10)]
the arguments are "name=value"
and "number=10"
.
Sourcepub fn get(&self, index: usize) -> Option<&MetaItem>
pub fn get(&self, index: usize) -> Option<&MetaItem>
Returns the MetaItem
in the given index, or None
if not found.
Sourcepub fn iter(&self) -> impl Iterator<Item = &MetaItem>
pub fn iter(&self) -> impl Iterator<Item = &MetaItem>
Returns an iterator over the arguments in this attribute.
Sourcepub fn into_name_values(self) -> Result<NameValueAttribute, NameValueError>
pub fn into_name_values(self) -> Result<NameValueAttribute, NameValueError>
Converts this macro attribute into a name-value attribute.
Sourcepub fn into_inner(self) -> Vec<MetaItem>
pub fn into_inner(self) -> Vec<MetaItem>
Converts this macro attribute into a list of its arguments.
Trait Implementations§
Source§impl Clone for MacroAttribute
impl Clone for MacroAttribute
Source§fn clone(&self) -> MacroAttribute
fn clone(&self) -> MacroAttribute
Returns a copy 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 moreSource§impl Debug for MacroAttribute
impl Debug for MacroAttribute
Source§impl Display for MacroAttribute
impl Display for MacroAttribute
Source§impl Hash for MacroAttribute
impl Hash for MacroAttribute
Source§impl<I: SliceIndex<[MetaItem]>> Index<I> for MacroAttribute
impl<I: SliceIndex<[MetaItem]>> Index<I> for MacroAttribute
Source§impl<'a> IntoIterator for &'a MacroAttribute
impl<'a> IntoIterator for &'a MacroAttribute
Source§impl IntoIterator for MacroAttribute
impl IntoIterator for MacroAttribute
Source§impl PartialEq for MacroAttribute
impl PartialEq for MacroAttribute
impl Eq for MacroAttribute
impl StructuralPartialEq for MacroAttribute
Auto Trait Implementations§
impl Freeze for MacroAttribute
impl RefUnwindSafe for MacroAttribute
impl !Send for MacroAttribute
impl !Sync for MacroAttribute
impl Unpin for MacroAttribute
impl UnwindSafe for MacroAttribute
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