pub enum MetaItem {
Path(String),
Literal(Lit),
NameValue(NameValue),
Nested(MacroAttribute),
}
Expand description
Represents the data in an attribute.
Variants§
Path(String)
A path like: #[attribute]
Literal(Lit)
A literal like: #[attribute("hello world")]
NameValue(NameValue)
A key-value like: #[attribute(key="value")]
or #[attribute(array=1,2,3,4)]
Nested(MacroAttribute)
Nested data like: #[attribute(inner("hello"))]
Implementations§
Source§impl MetaItem
impl MetaItem
Sourcepub fn is_literal(&self) -> bool
pub fn is_literal(&self) -> bool
Returns true
if this meta item is a literal like: #[attribute("hola mundo")]
.
Sourcepub fn is_name_value(&self) -> bool
pub fn is_name_value(&self) -> bool
Returns true
if this meta item is a name-value pair like: #[attribute(name="value")]
.
Sourcepub fn is_nested(&self) -> bool
pub fn is_nested(&self) -> bool
Returns true
if this meta item is a nested attribute like: #[attribute(inner("hello"))]
.
Sourcepub fn into_path(self) -> Option<String>
pub fn into_path(self) -> Option<String>
Converts this meta item into a String
or None
if is not a path.
Sourcepub fn into_literal(self) -> Option<Lit>
pub fn into_literal(self) -> Option<Lit>
Converts this meta item into a Lit
or None
if is not a literal.
Sourcepub fn into_name_value(self) -> Option<NameValue>
pub fn into_name_value(self) -> Option<NameValue>
Converts this meta item into a NameValue
or None
if is not a name-value pair.
Sourcepub fn into_nested(self) -> Option<MacroAttribute>
pub fn into_nested(self) -> Option<MacroAttribute>
Converts this meta item into a its inner MacroAttribute
or None
if is not a nested attribute.
Sourcepub fn as_path(&self) -> Option<&str>
pub fn as_path(&self) -> Option<&str>
Returns a reference to this meta item as a &str
or None
if is not a path.
Sourcepub fn as_literal(&self) -> Option<&Lit>
pub fn as_literal(&self) -> Option<&Lit>
Returns a reference to this meta item as a Lit
or None
if is not a literal.
Sourcepub fn as_name_value(&self) -> Option<&NameValue>
pub fn as_name_value(&self) -> Option<&NameValue>
Returns a reference to this meta item as a NameValue
or None
if is not a name-value pair.
Sourcepub fn as_nested(&self) -> Option<&MacroAttribute>
pub fn as_nested(&self) -> Option<&MacroAttribute>
Returns a reference to this meta item as a nested macro attribute or None
if is not a macro attribute.