stringcase for Rust

This library provides some functions that convert string cases between Ada_Case, camelCase, COBOL-CASE, kebab-case, MACRO_CASE, PascalCase, snake_case, Title Case, and Train-Case.
In addition, generic functions capitalize, lowerize, and upperize are provided to convert
string cases with a custom joiner character.
And this library also provides a trait Caser which enables strings to convert themselves to their cases by their own methods.
Basically, these functions only target ASCII uppercase and lowercase letters for capitalization. All characters other than ASCII uppercase and lowercase letters and ASCII numbers are removed as word separators.
If you want to use some symbols as separators, specify those symbols in the separators field of Options struct and use the 〜case_with_options function for the desired case.
If you want to retain certain symbols and use everything else as separators, specify those symbols in keep field of Options struct and use the 〜case_with_options function for the desired case.
Additionally, you can specify whether to place word boundaries before and/or after non-alphabetic characters with conversion options.
This can be set using the separate_before_non_alphabets and separate_after_non_alphabets fields in the Options struct.
The 〜_case functions that do not take Options as an argument only place word boundaries after non-alphabetic characters.
In other words, they behave as if separate_before_non_alphabets = false and separate_after_non_alphabets = true.
Installation
In Cargo.toml, write this crate as a dependency.
[]
= "1.0.0"
Usage
The functions in this crate can be executed as follows:
use snake_case;
If you want the conversion to behave differently, use 〜_case_with_options.
use ;
You can also use the generic functions capitalize, lowerize, and upperize to convert
strings into capitalized, lowercased, or uppercased words joined by a custom joiner
character:
use ;
And by bringing Caser with use declaration, it will be able to execute methods of strings, String or &str, to convert themselves to their cases.
use ;
Supporting Rust versions
This library supports Rust 1.56.1 or later.
)
License
Copyright (C) 2024-2026 Takayuki Sato
This program is free software under MIT License. See the file LICENSE in this distribution for more details.