@@ -295,6 +295,35 @@ fn namespace_from_package_name(package_name: &str) -> String {
295295}
296296
297297impl Config {
298+ fn namespace_of_package_name ( s : & str ) -> String {
299+ let len = s. len ( ) ;
300+ let mut buf = String :: with_capacity ( len) ;
301+
302+ fn aux ( s : & str , capital : bool , buf : & mut String , off : usize ) {
303+ if off >= s. len ( ) {
304+ return ;
305+ }
306+
307+ let ch = s. as_bytes ( ) [ off] as char ;
308+ match ch {
309+ 'a' ..='z' | 'A' ..='Z' | '0' ..='9' | '_' => {
310+ let new_capital = false ;
311+ buf. push ( if capital { ch. to_ascii_uppercase ( ) } else { ch } ) ;
312+ aux ( s, new_capital, buf, off + 1 ) ;
313+ }
314+ '/' | '-' => {
315+ aux ( s, true , buf, off + 1 ) ;
316+ }
317+ _ => {
318+ aux ( s, capital, buf, off + 1 ) ;
319+ }
320+ }
321+ }
322+
323+ aux ( s, true , & mut buf, 0 ) ;
324+ buf
325+ }
326+
298327 pub fn get_namespace ( & self ) -> packages:: Namespace {
299328 let namespace_from_package = namespace_from_package_name ( & self . name ) ;
300329 match ( self . namespace . as_ref ( ) , self . namespace_entry . as_ref ( ) ) {
@@ -312,7 +341,8 @@ impl Config {
312341 namespace if namespace. is_case ( Case :: UpperFlat ) => {
313342 packages:: Namespace :: Namespace ( namespace. to_string ( ) )
314343 }
315- namespace => packages:: Namespace :: Namespace ( namespace. to_string ( ) . to_case ( Case :: Pascal ) ) ,
344+ namespace => packages:: Namespace :: Namespace ( Self :: namespace_of_package_name ( namespace) ) ,
345+ // namespace.to_string().to_case(Case::Pascal)),
316346 } ,
317347 ( Some ( self :: NamespaceConfig :: String ( str) ) , Some ( entry) ) => match str. as_str ( ) {
318348 "true" => packages:: Namespace :: NamespaceWithEntry {
0 commit comments