Flatten ItemKind into an Item enum
Side note: this pattern is sort of nice:
let item: &Item = /* ... */;
match *item {
Item::Mod(ref item) => {
do_something_with(&item.ident, &item.content);
}
Item::Fn(ref item) => {
do_something_with(&item.abi, &item.block);
}
/* ... */
}
Basically pattern matching on an `item` and rebinding the same name `item`
just takes your variable and imbues it with those additional fields that exist
on the type of item that it happens to be.
diff --git a/tests/test_expr.rs b/tests/test_expr.rs
index 14c0cae..5967aa6 100644
--- a/tests/test_expr.rs
+++ b/tests/test_expr.rs
@@ -88,11 +88,11 @@
let actual: File = syn::parse_str(raw).unwrap();
- assert_let!(ItemKind::Struct(ItemStruct { ref ident, .. }) = actual.items[0].node; {
+ assert_let!(Item::Struct(ItemStruct { ref ident, .. }) = actual.items[0]; {
assert_eq!(ident, "catch");
});
- assert_let!(Item { node: ItemKind::Fn(ItemFn { ref block, .. }), .. } = actual.items[1]; {
+ assert_let!(Item::Fn(ItemFn { ref block, .. }) = actual.items[1]; {
assert_let!(Stmt::Local(ref local) = block.stmts[0]; {
assert_let!(Local { init: Some(ref init_expr), .. } = **local; {
assert_let!(Expr { node: ExprKind::Catch(..), .. } = **init_expr);