#string #camel-case #snake-case #pascal-case #convert-string #cases #normalize

normalize-case

A small Rust library for normalizing string cases (snake_case, camelCase, PascalCase, etc.)

3 releases

new 0.1.2 Nov 21, 2024
0.1.1 Oct 31, 2024
0.1.0 Oct 29, 2024

#1145 in Algorithms

Download history 210/week @ 2024-10-25 52/week @ 2024-11-01 6/week @ 2024-11-08 109/week @ 2024-11-15

379 downloads per month

MIT license

5KB
56 lines

normalize-case

A small, dependency-free Rust library for converting strings to various cases: snake_case, camelCase, and PascalCase.

Overview

normalize-case provides simple and efficient functions to convert string cases, ideal for Rust applications that require case normalization for structured data, configuration keys, or general text formatting.

Installation

Add normalize-case to your Cargo.toml:

[dependencies]
normalize-case = "0.1.0"```

## Usage
```rust
use normalize_case::{to_snake_case, to_camel_case, to_pascal_case};

fn main() {
    assert_eq!(to_snake_case("HelloWorld"), "hello_world");
    assert_eq!(to_camel_case("hello_world"), "helloWorld");
    assert_eq!(to_pascal_case("hello-world"), "HelloWorld");
}

Available Functions

to_snake_case(s: &str) -> String: Converts a string to snake_case. to_camel_case(s: &str) -> String: Converts a string to camelCase. to_pascal_case(s: &str) -> String: Converts a string to PascalCase. Contributing Contributions are welcome! Please feel free to submit a pull request or report issues.

License

This project is licensed under the MIT License

Author

bensatlantik

No runtime deps