@@ -29,7 +29,10 @@ impl From<clean::Item> for Item {
2929 id : def_id. into ( ) ,
3030 crate_id : def_id. krate . as_u32 ( ) ,
3131 name,
32- stripped : inner == clean:: StrippedItem ( _) ,
32+ stripped : match inner {
33+ clean:: StrippedItem ( _) => true ,
34+ _ => false ,
35+ } ,
3336 source : source. into ( ) ,
3437 visibility : visibility. into ( ) ,
3538 docs : attrs. collapsed_doc_value ( ) . unwrap_or_default ( ) ,
@@ -179,27 +182,18 @@ impl From<clean::ItemEnum> for ItemEnum {
179182 bounds : g. into_iter ( ) . map ( Into :: into) . collect ( ) ,
180183 default : t. map ( Into :: into) ,
181184 } ,
182- StrippedItem ( inner) => ItemEnum :: StrippedItem ( Box :: new ( ( * inner) . into ( ) ) ) ,
185+ StrippedItem ( inner) => ( * inner) . into ( ) ,
183186 _ => panic ! ( "{:?} is not supported for JSON output" , item) ,
184187 }
185188 }
186189}
187190
188- fn remove_stripped ( items : & [ clean:: Item ] ) -> Vec < Id > {
189- items
190- . into_iter ( )
191- . filter_map ( |i| {
192- if let clean:: StrippedItem ( _) = i. inner {
193- return None ;
194- }
195- Some ( i. def_id . into ( ) )
196- } )
197- . collect ( )
198- }
199-
200191impl From < clean:: Module > for Module {
201192 fn from ( module : clean:: Module ) -> Self {
202- Module { is_crate : module. is_crate , items : remove_stripped ( & module. items ) }
193+ Module {
194+ is_crate : module. is_crate ,
195+ items : module. items . into_iter ( ) . map ( |i| i. def_id . into ( ) ) . collect ( ) ,
196+ }
203197 }
204198}
205199
@@ -210,7 +204,7 @@ impl From<clean::Struct> for Struct {
210204 struct_type : struct_type. into ( ) ,
211205 generics : generics. into ( ) ,
212206 fields_stripped,
213- fields : remove_stripped ( & fields) ,
207+ fields : fields. into_iter ( ) . map ( |i| i . def_id . into ( ) ) . collect ( ) ,
214208 impls : Vec :: new ( ) , // Added in JsonRenderer::item
215209 }
216210 }
@@ -223,7 +217,7 @@ impl From<clean::Union> for Struct {
223217 struct_type : struct_type. into ( ) ,
224218 generics : generics. into ( ) ,
225219 fields_stripped,
226- fields : remove_stripped ( & fields) ,
220+ fields : fields. into_iter ( ) . map ( |i| i . def_id . into ( ) ) . collect ( ) ,
227221 impls : Vec :: new ( ) , // Added in JsonRenderer::item
228222 }
229223 }
@@ -410,7 +404,7 @@ impl From<clean::Trait> for Trait {
410404 Trait {
411405 is_auto : auto,
412406 is_unsafe : unsafety == rustc_hir:: Unsafety :: Unsafe ,
413- items : remove_stripped ( & items) ,
407+ items : items. into_iter ( ) . map ( |i| i . def_id . into ( ) ) . collect ( ) ,
414408 generics : generics. into ( ) ,
415409 bounds : bounds. into_iter ( ) . map ( Into :: into) . collect ( ) ,
416410 implementors : Vec :: new ( ) , // Added in JsonRenderer::item
@@ -437,7 +431,7 @@ impl From<clean::Impl> for Impl {
437431 provided_trait_methods : provided_trait_methods. into_iter ( ) . collect ( ) ,
438432 trait_ : trait_. map ( Into :: into) ,
439433 for_ : for_. into ( ) ,
440- items : remove_stripped ( & items) ,
434+ items : items. into_iter ( ) . map ( |i| i . def_id . into ( ) ) . collect ( ) ,
441435 negative : polarity == Some ( clean:: ImplPolarity :: Negative ) ,
442436 synthetic,
443437 blanket_impl : blanket_impl. map ( Into :: into) ,
@@ -476,7 +470,7 @@ impl From<clean::Enum> for Enum {
476470 Enum {
477471 generics : generics. into ( ) ,
478472 variants_stripped,
479- variants : remove_stripped ( & variants. into_iter ( ) . collect :: < Vec < _ > > ( ) ) ,
473+ variants : variants. into_iter ( ) . map ( |i| i . def_id . into ( ) ) . collect ( ) ,
480474 impls : Vec :: new ( ) , // Added in JsonRenderer::item
481475 }
482476 }
@@ -489,7 +483,7 @@ impl From<clean::VariantStruct> for Struct {
489483 struct_type : struct_type. into ( ) ,
490484 generics : Default :: default ( ) ,
491485 fields_stripped,
492- fields : remove_stripped ( & fields) ,
486+ fields : fields. into_iter ( ) . map ( |i| i . def_id . into ( ) ) . collect ( ) ,
493487 impls : Vec :: new ( ) ,
494488 }
495489 }
@@ -501,7 +495,7 @@ impl From<clean::Variant> for Variant {
501495 match variant. kind {
502496 CLike => Variant :: Plain ,
503497 Tuple ( t) => Variant :: Tuple ( t. into_iter ( ) . map ( Into :: into) . collect ( ) ) ,
504- Struct ( s) => Variant :: Struct ( remove_stripped ( & s. fields ) ) ,
498+ Struct ( s) => Variant :: Struct ( s. fields . into_iter ( ) . map ( |i| i . def_id . into ( ) ) . collect ( ) ) ,
505499 }
506500 }
507501}
0 commit comments