@@ -565,6 +565,46 @@ impl LinkSelfContainedComponents {
565
565
_ => return None ,
566
566
} )
567
567
}
568
+
569
+ /// Return the component's name.
570
+ ///
571
+ /// Returns `None` if the bitflags aren't a singular component (but a mix of multiple flags).
572
+ pub fn as_str ( self ) -> Option < & ' static str > {
573
+ Some ( match self {
574
+ LinkSelfContainedComponents :: CRT_OBJECTS => "crto" ,
575
+ LinkSelfContainedComponents :: LIBC => "libc" ,
576
+ LinkSelfContainedComponents :: UNWIND => "unwind" ,
577
+ LinkSelfContainedComponents :: LINKER => "linker" ,
578
+ LinkSelfContainedComponents :: SANITIZERS => "sanitizers" ,
579
+ LinkSelfContainedComponents :: MINGW => "mingw" ,
580
+ _ => return None ,
581
+ } )
582
+ }
583
+
584
+ /// Returns an array of all the components.
585
+ fn all_components ( ) -> [ LinkSelfContainedComponents ; 6 ] {
586
+ [
587
+ LinkSelfContainedComponents :: CRT_OBJECTS ,
588
+ LinkSelfContainedComponents :: LIBC ,
589
+ LinkSelfContainedComponents :: UNWIND ,
590
+ LinkSelfContainedComponents :: LINKER ,
591
+ LinkSelfContainedComponents :: SANITIZERS ,
592
+ LinkSelfContainedComponents :: MINGW ,
593
+ ]
594
+ }
595
+ }
596
+
597
+ impl IntoIterator for LinkSelfContainedComponents {
598
+ type Item = LinkSelfContainedComponents ;
599
+ type IntoIter = std:: vec:: IntoIter < LinkSelfContainedComponents > ;
600
+
601
+ fn into_iter ( self ) -> Self :: IntoIter {
602
+ LinkSelfContainedComponents :: all_components ( )
603
+ . into_iter ( )
604
+ . filter ( |& s| self . contains ( s) )
605
+ . collect :: < Vec < _ > > ( )
606
+ . into_iter ( )
607
+ }
568
608
}
569
609
570
610
#[ derive( Clone , Copy , Debug , PartialEq , Hash , Encodable , Decodable , HashStable_Generic ) ]
0 commit comments