@@ -2441,6 +2441,13 @@ impl Item {
2441
2441
}
2442
2442
}
2443
2443
2444
+ impl < K : IntoItemKind > Item < K > {
2445
+ pub fn into_item ( self ) -> Item {
2446
+ let Item { attrs, id, span, vis, ident, kind, tokens } = self ;
2447
+ Item { attrs, id, span, vis, ident, kind : kind. into_item_kind ( ) , tokens }
2448
+ }
2449
+ }
2450
+
2444
2451
/// `extern` qualifier on a function item or function type.
2445
2452
#[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug ) ]
2446
2453
pub enum Extern {
@@ -2617,6 +2624,10 @@ impl ItemKind {
2617
2624
}
2618
2625
}
2619
2626
2627
+ pub trait IntoItemKind {
2628
+ fn into_item_kind ( self ) -> ItemKind ;
2629
+ }
2630
+
2620
2631
// FIXME(Centril): These definitions should be unmerged;
2621
2632
// see https://github.com/rust-lang/rust/pull/69194#discussion_r379899975
2622
2633
pub type ForeignItem = Item < AssocItemKind > ;
@@ -2656,3 +2667,15 @@ impl AssocItemKind {
2656
2667
}
2657
2668
}
2658
2669
}
2670
+
2671
+ impl IntoItemKind for AssocItemKind {
2672
+ fn into_item_kind ( self ) -> ItemKind {
2673
+ match self {
2674
+ AssocItemKind :: Const ( a, b, c) => ItemKind :: Const ( a, b, c) ,
2675
+ AssocItemKind :: Static ( a, b, c) => ItemKind :: Static ( a, b, c) ,
2676
+ AssocItemKind :: Fn ( a, b, c, d) => ItemKind :: Fn ( a, b, c, d) ,
2677
+ AssocItemKind :: TyAlias ( a, b, c, d) => ItemKind :: TyAlias ( a, b, c, d) ,
2678
+ AssocItemKind :: Macro ( a) => ItemKind :: Mac ( a) ,
2679
+ }
2680
+ }
2681
+ }
0 commit comments