pub fn to_pascal_case(s: &str) -> StringExpand description
Convert string to PascalCase.
Converts snake_case and other formats to PascalCase by capitalizing the first
letter of every word and removing separators. First word is also capitalized.
Edge cases:
- All words are capitalized (unlike camelCase)
- Non-alphanumeric characters are treated as separators
- Leading/trailing separators are removed
ยงExamples
use spikard_cli::codegen::common::case_conversion::to_pascal_case;
assert_eq!(to_pascal_case("user"), "User");
assert_eq!(to_pascal_case("get_user"), "GetUser");
assert_eq!(to_pascal_case("create_user_profile"), "CreateUserProfile");
assert_eq!(to_pascal_case("http_server"), "HttpServer");
assert_eq!(to_pascal_case("graphql-type"), "GraphqlType");