@@ -2441,6 +2441,13 @@ impl Item {
24412441 }
24422442}
24432443
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+
24442451/// `extern` qualifier on a function item or function type.
24452452#[ derive( Clone , Copy , RustcEncodable , RustcDecodable , Debug ) ]
24462453pub enum Extern {
@@ -2617,6 +2624,10 @@ impl ItemKind {
26172624 }
26182625}
26192626
2627+ pub trait IntoItemKind {
2628+ fn into_item_kind ( self ) -> ItemKind ;
2629+ }
2630+
26202631// FIXME(Centril): These definitions should be unmerged;
26212632// see https://github.com/rust-lang/rust/pull/69194#discussion_r379899975
26222633pub type ForeignItem = Item < AssocItemKind > ;
@@ -2656,3 +2667,15 @@ impl AssocItemKind {
26562667 }
26572668 }
26582669}
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