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