Extern types
diff --git a/src/item.rs b/src/item.rs
index 30a4a58..ff36380 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -297,6 +297,14 @@
pub ty: Box<Type>,
pub semi_token: Token![;],
}),
+ /// A foreign type
+ pub Type(ForeignItemType {
+ pub attrs: Vec<Attribute>,
+ pub vis: Visibility,
+ pub type_token: Token![type],
+ pub ident: Ident,
+ pub semi_token: Token![;],
+ }),
}
}
@@ -814,6 +822,8 @@
syn!(ForeignItemFn) => { ForeignItem::Fn }
|
syn!(ForeignItemStatic) => { ForeignItem::Static }
+ |
+ syn!(ForeignItemType) => { ForeignItem::Type }
));
impl_synom!(ForeignItemFn "foreign function" do_parse!(
@@ -876,6 +886,21 @@
})
));
+ impl_synom!(ForeignItemType "foreign type" do_parse!(
+ attrs: many0!(call!(Attribute::parse_outer)) >>
+ vis: syn!(Visibility) >>
+ type_: keyword!(type) >>
+ ident: syn!(Ident) >>
+ semi: punct!(;) >>
+ (ForeignItemType {
+ attrs: attrs,
+ vis: vis,
+ type_token: type_,
+ ident: ident,
+ semi_token: semi,
+ })
+ ));
+
impl_synom!(ItemType "type item" do_parse!(
attrs: many0!(call!(Attribute::parse_outer)) >>
vis: syn!(Visibility) >>
@@ -1686,6 +1711,16 @@
}
}
+ impl ToTokens for ForeignItemType {
+ fn to_tokens(&self, tokens: &mut Tokens) {
+ tokens.append_all(self.attrs.outer());
+ self.vis.to_tokens(tokens);
+ self.type_token.to_tokens(tokens);
+ self.ident.to_tokens(tokens);
+ self.semi_token.to_tokens(tokens);
+ }
+ }
+
impl ToTokens for MethodSig {
fn to_tokens(&self, tokens: &mut Tokens) {
self.constness.to_tokens(tokens);