22// SPDX-License-Identifier: Apache-2.0
33// SPDX-License-Identifier: MIT
44
5+ use heck:: AsShoutySnakeCase ;
6+ use heck:: AsSnakeCase ;
57use heck:: ToSnakeCase ;
8+
69use once_cell:: sync:: OnceCell ;
710
811use std:: { path:: Path , sync:: Mutex } ;
@@ -19,12 +22,9 @@ fn has_feature(feature: &str) -> bool {
1922
2023 // when a feature is enabled, Cargo sets the `CARGO_FEATURE_<name` env var to 1
2124 // https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
22- std:: env:: var ( format ! (
23- "CARGO_FEATURE_{}" ,
24- feature. to_snake_case( ) . to_uppercase( )
25- ) )
26- . map ( |x| x == "1" )
27- . unwrap_or ( false )
25+ std:: env:: var ( format ! ( "CARGO_FEATURE_{}" , AsShoutySnakeCase ( feature) ) )
26+ . map ( |x| x == "1" )
27+ . unwrap_or ( false )
2828}
2929
3030// creates a cfg alias if `has_feature` is true.
@@ -148,11 +148,11 @@ fn alias_module(module: &str, apis: &[&str], api_all: bool) {
148148 for api in apis {
149149 let has = has_feature ( & format ! ( "{}-{}" , module, api) ) || all;
150150 alias (
151- & format ! ( "{}_{}" , module . to_snake_case ( ) , api . to_snake_case ( ) ) ,
151+ & format ! ( "{}_{}" , AsSnakeCase ( module ) , AsSnakeCase ( api ) ) ,
152152 has,
153153 ) ;
154154 any = any || has;
155155 }
156156
157- alias ( & format ! ( "{}_any" , module . to_snake_case ( ) ) , any) ;
157+ alias ( & format ! ( "{}_any" , AsSnakeCase ( module ) ) , any) ;
158158}
0 commit comments