Crates.io | normalize-case |
lib.rs | normalize-case |
version | 0.1.2 |
source | src |
created_at | 2024-10-29 13:34:49.374308 |
updated_at | 2024-11-21 01:30:11.557848 |
description | A small Rust library for normalizing string cases (snake_case, camelCase, PascalCase, etc.) |
homepage | |
repository | |
max_upload_size | |
id | 1427006 |
size | 4,691 |
A small, dependency-free Rust library for converting strings to various cases: snake_case
, camelCase
, and PascalCase
.
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.
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");
}
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.
This project is licensed under the MIT License
bensatlantik