Derive for remote types

This commit is contained in:
David Tolnay
2017-04-08 22:42:42 -07:00
parent cc933b9cdb
commit a6d172111b
7 changed files with 620 additions and 242 deletions
+9 -2
View File
@@ -1,5 +1,6 @@
use syn;
use attr;
use check;
use Ctxt;
pub struct Item<'a> {
@@ -62,12 +63,14 @@ impl<'a> Item<'a> {
}
}
Item {
let item = Item {
ident: item.ident.clone(),
attrs: attrs,
body: body,
generics: &item.generics,
}
};
check::check(cx, &item);
item
}
}
@@ -81,6 +84,10 @@ impl<'a> Body<'a> {
Body::Struct(_, ref fields) => Box::new(fields.iter()),
}
}
pub fn has_getter(&self) -> bool {
self.all_fields().any(|f| f.attrs.getter().is_some())
}
}
fn enum_from_ast<'a>(cx: &Ctxt, variants: &'a [syn::Variant]) -> Vec<Variant<'a>> {