pub fn to_snake_case(input: &str) -> StringExpand description
Converts a string to snake_case.
Transforms input into snake_case format where all letters are lowercase and words are separated by underscores. Converts from camelCase, PascalCase, kebab-case, or space-separated formats.
§Use Cases
- Database Schema: Convert field names to SQL column conventions
- Python/Ruby: Transform names to language naming conventions
- Configuration Files: Normalize setting names
§Examples
use redstr::to_snake_case;
assert_eq!(to_snake_case("HelloWorld"), "hello_world");
assert_eq!(to_snake_case("getUserId"), "get_user_id");
assert_eq!(to_snake_case("API Response"), "api_response");
assert_eq!(to_snake_case("user-first-name"), "user_first_name");