commit | 8e661e296d33884345456c8f6f11f2ab5e07acff | [log] [tgz] |
---|---|---|
author | David Tolnay <dtolnay@gmail.com> | Tue Sep 27 00:00:04 2016 -0700 |
committer | David Tolnay <dtolnay@gmail.com> | Tue Sep 27 00:00:04 2016 -0700 |
tree | 81c860fcc37a82f94d10f0493047536a862c267a | |
parent | 5a0647501ce77d57284b42e596313d1d79653bb0 [diff] [blame] |
Method to get name of meta item
diff --git a/src/attr.rs b/src/attr.rs index 8d36b34..0c5b24b 100644 --- a/src/attr.rs +++ b/src/attr.rs
@@ -26,6 +26,16 @@ NameValue(Ident, Lit), } +impl MetaItem { + pub fn name(&self) -> &str { + match *self { + MetaItem::Word(ref name) => name.as_ref(), + MetaItem::List(ref name, _) => name.as_ref(), + MetaItem::NameValue(ref name, _) => name.as_ref(), + } + } +} + #[cfg(feature = "parsing")] pub mod parsing { use super::*;