pub fn Pascalize(Text: &str) -> StringExpand description
use crate::Maintain::Source::Build::Pascalize;
let result = Pascalize("development");
assert_eq!(result, "Development");use crate::Maintain::Source::Build::Pascalize;
let result = Pascalize("node_environment");
assert_eq!(result, "NodeEnvironment");use crate::Maintain::Source::Build::Pascalize;
let result = Pascalize("tauri-apps_tauri");
assert_eq!(result, "TauriAppsTauri");Converts a kebab-case or snake_case string to PascalCase.
This function processes strings separated by hyphens (-) or underscores (_)
and converts them to PascalCase by capitalizing the first letter of each word.
The function handles strings with single or multiple delimiters and filters
out empty segments.
§Parameters
Text- The input string to convert (kebab-case or snake_case)
§Returns
A new String in PascalCase format.
§Behavior
- Splits the input on both hyphen (
-) and underscore (_) characters - Filters out empty segments (from consecutive delimiters)
- Capitalizes the first character of each segment
- Preserves the case of remaining characters
- Joins all segments together without delimiters
§Examples
use crate::Maintain::Source::Build::Pascalize;
assert_eq!(Pascalize("development"), "Development");
assert_eq!(Pascalize("node_environment"), "NodeEnvironment");
assert_eq!(Pascalize("tauri-apps"), "TauriApps");
assert_eq!(Pascalize("my-app_name"), "MyAppName");§Edge Cases
- Empty string returns an empty string
- Strings with only delimiters return an empty string
- Single word strings are capitalized
- Words already in PascalCase are not modified (no delimiter detection)