@@ -93,24 +93,36 @@ macro_rules! ascii_case_insensitive_phf_map {
93
93
ascii_case_insensitive_phf_map!( $name -> $ValueType = { $( $key => $value, ) + } )
94
94
} ;
95
95
( $name: ident -> $ValueType: ty = { $( $key: tt => $value: expr, ) + } ) => {
96
- mod $name {
97
- use $crate:: _cssparser_internal_phf as phf;
96
+ use $crate:: _cssparser_internal_phf as phf;
97
+
98
+ // See macro above for context.
99
+ mod cssparser_internal {
98
100
$crate:: _cssparser_internal_max_len! {
99
101
$( $key ) +
100
102
}
101
- static MAP : phf:: Map <& ' static str , $ValueType> = phf:: phf_map! {
102
- $(
103
- $key => $value,
104
- ) *
105
- } ;
103
+ }
104
+
105
+ static MAP : phf:: Map <& ' static str , $ValueType> = phf:: phf_map! {
106
+ $(
107
+ $key => $value,
108
+ ) *
109
+ } ;
106
110
111
+ // While the obvious choice for this would be an inner module, it's not possible to
112
+ // reference from types from there, see:
113
+ // <https://github.com/rust-lang/rust/issues/114369>
114
+ //
115
+ // So we abuse a struct with static associated functions instead.
116
+ #[ allow( non_camel_case_types) ]
117
+ struct $name;
118
+ impl $name {
107
119
#[ allow( dead_code) ]
108
- pub fn entries( ) -> impl Iterator <Item = ( & ' static & ' static str , & ' static $ValueType) > {
120
+ fn entries( ) -> impl Iterator <Item = ( & ' static & ' static str , & ' static $ValueType) > {
109
121
MAP . entries( )
110
122
}
111
123
112
- pub fn get( input: & str ) -> Option <& ' static $ValueType> {
113
- $crate:: _cssparser_internal_to_lowercase!( input, MAX_LENGTH => lowercase) ;
124
+ fn get( input: & str ) -> Option <& ' static $ValueType> {
125
+ $crate:: _cssparser_internal_to_lowercase!( input, cssparser_internal :: MAX_LENGTH => lowercase) ;
114
126
MAP . get( lowercase?)
115
127
}
116
128
}
0 commit comments