1
1
use std:: collections:: { BTreeSet , HashMap , HashSet } ;
2
+ use std:: iter;
2
3
use std:: process:: Command ;
3
- use std:: str:: FromStr ;
4
4
use std:: sync:: OnceLock ;
5
- use std:: { fmt, iter} ;
6
5
7
6
use build_helper:: git:: GitConfig ;
8
7
use camino:: { Utf8Path , Utf8PathBuf } ;
@@ -12,48 +11,7 @@ use serde::de::{Deserialize, Deserializer, Error as _};
12
11
pub use self :: Mode :: * ;
13
12
use crate :: executor:: { ColorConfig , OutputFormat } ;
14
13
use 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} ;
57
15
58
16
string_enum ! {
59
17
#[ derive( Clone , Copy , PartialEq , Debug ) ]
0 commit comments