@@ -76,31 +76,31 @@ fn find_relative_libdir(sysroot: &Path) -> std::borrow::Cow<'static, str> {
76
76
macro_rules! target_spec_enum {
77
77
(
78
78
$( #[ $attr: meta] ) *
79
- pub enum $name : ident {
79
+ pub enum $Name : ident {
80
80
$(
81
81
$( #[ $variant_attr: meta] ) *
82
- $variant : ident = $string: literal,
82
+ $Variant : ident = $string: literal,
83
83
) *
84
84
}
85
85
parse_error_type = $parse_error_type: literal;
86
86
) => {
87
87
$( #[ $attr] ) *
88
88
#[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug , PartialOrd , Ord ) ]
89
89
#[ derive( schemars:: JsonSchema ) ]
90
- pub enum $name {
90
+ pub enum $Name {
91
91
$(
92
92
$( #[ $variant_attr] ) *
93
93
#[ serde( rename = $string) ] // for JSON schema generation only
94
- $variant ,
94
+ $Variant ,
95
95
) *
96
96
}
97
97
98
- impl FromStr for $name {
98
+ impl FromStr for $Name {
99
99
type Err = String ;
100
100
101
101
fn from_str( s: & str ) -> Result <Self , Self :: Err > {
102
102
Ok ( match s {
103
- $( $string => Self :: $variant , ) *
103
+ $( $string => Self :: $Variant , ) *
104
104
_ => {
105
105
let all = [ $( concat!( "'" , $string, "'" ) ) ,* ] . join( ", " ) ;
106
106
return Err ( format!( "invalid {}: '{s}'. allowed values: {all}" , $parse_error_type) ) ;
@@ -109,24 +109,25 @@ macro_rules! target_spec_enum {
109
109
}
110
110
}
111
111
112
- impl $name {
112
+ impl $Name {
113
+ pub const ALL : & ' static [ $Name] = & [ $( $Name:: $Variant, ) * ] ;
113
114
pub fn desc( & self ) -> & ' static str {
114
115
match self {
115
- $( Self :: $variant => $string, ) *
116
+ $( Self :: $Variant => $string, ) *
116
117
}
117
118
}
118
119
}
119
120
120
- impl crate :: json:: ToJson for $name {
121
+ impl crate :: json:: ToJson for $Name {
121
122
fn to_json( & self ) -> crate :: json:: Json {
122
123
self . desc( ) . to_json( )
123
124
}
124
125
}
125
126
126
- crate :: json:: serde_deserialize_from_str!( $name ) ;
127
+ crate :: json:: serde_deserialize_from_str!( $Name ) ;
127
128
128
129
129
- impl std:: fmt:: Display for $name {
130
+ impl std:: fmt:: Display for $Name {
130
131
fn fmt( & self , f: & mut std:: fmt:: Formatter <' _>) -> std:: fmt:: Result {
131
132
f. write_str( self . desc( ) )
132
133
}
0 commit comments