11use std:: collections:: { BTreeSet , HashMap , HashSet } ;
2+ use std:: iter;
23use std:: process:: Command ;
3- use std:: str:: FromStr ;
44use std:: sync:: OnceLock ;
5- use std:: { fmt, iter} ;
65
76use build_helper:: git:: GitConfig ;
87use camino:: { Utf8Path , Utf8PathBuf } ;
@@ -12,48 +11,7 @@ use serde::de::{Deserialize, Deserializer, Error as _};
1211pub use self :: Mode :: * ;
1312use crate :: executor:: { ColorConfig , OutputFormat } ;
1413use crate :: fatal;
15- use crate :: util:: { Utf8PathBufExt , add_dylib_path} ;
16-
17- macro_rules! string_enum {
18- ( $( #[ $meta: meta] ) * $vis: vis enum $name: ident { $( $variant: ident => $repr: expr, ) * } ) => {
19- $( #[ $meta] ) *
20- $vis enum $name {
21- $( $variant, ) *
22- }
23-
24- impl $name {
25- $vis const VARIANTS : & ' static [ Self ] = & [ $( Self :: $variant, ) * ] ;
26- $vis const STR_VARIANTS : & ' static [ & ' static str ] = & [ $( Self :: $variant. to_str( ) , ) * ] ;
27-
28- $vis const fn to_str( & self ) -> & ' static str {
29- match self {
30- $( Self :: $variant => $repr, ) *
31- }
32- }
33- }
34-
35- impl fmt:: Display for $name {
36- fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
37- fmt:: Display :: fmt( self . to_str( ) , f)
38- }
39- }
40-
41- impl FromStr for $name {
42- type Err = String ;
43-
44- fn from_str( s: & str ) -> Result <Self , Self :: Err > {
45- match s {
46- $( $repr => Ok ( Self :: $variant) , ) *
47- _ => Err ( format!( concat!( "unknown `" , stringify!( $name) , "` variant: `{}`" ) , s) ) ,
48- }
49- }
50- }
51- }
52- }
53-
54- // Make the macro visible outside of this module, for tests.
55- #[ cfg( test) ]
56- pub ( crate ) use string_enum;
14+ use crate :: util:: { Utf8PathBufExt , add_dylib_path, string_enum} ;
5715
5816string_enum ! {
5917 #[ derive( Clone , Copy , PartialEq , Debug ) ]
0 commit comments