]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/ast.rs
auto merge of #14696 : jakub-/rust/dead-struct-fields, r=alexcrichton
[rust.git] / src / libsyntax / ast.rs
index 9c3960d0f0622328299856e3363b5c4e878be690..2f5459b6f2e1b47801c1efcf6193f5495f95b26d 100644 (file)
@@ -1053,6 +1053,15 @@ pub struct StructField_ {
     pub attrs: Vec<Attribute>,
 }
 
+impl StructField_ {
+    pub fn ident(&self) -> Option<Ident> {
+        match self.kind {
+            NamedField(ref ident, _) => Some(ident.clone()),
+            UnnamedField(_) => None
+        }
+    }
+}
+
 pub type StructField = Spanned<StructField_>;
 
 #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)]