| 1 |
# **heck** is a case conversion library |
| 2 |
|
| 3 |
 |
| 4 |
|
| 5 |
This library exists to provide case conversion between common cases like |
| 6 |
CamelCase and snake_case. It is intended to be unicode aware, internally |
| 7 |
consistent, and reasonably well performing. |
| 8 |
|
| 9 |
## Definition of a word boundary |
| 10 |
|
| 11 |
Word boundaries are defined by non-alphanumeric characters, as well as |
| 12 |
within those words in this manner: |
| 13 |
|
| 14 |
1. If an uppercase character is followed by lowercase letters, a word |
| 15 |
boundary is considered to be just prior to that uppercase character. |
| 16 |
2. If multiple uppercase characters are consecutive, they are considered to |
| 17 |
be within a single word, except that the last will be part of the next word |
| 18 |
if it is followed by lowercase characters (see rule 1). |
| 19 |
|
| 20 |
That is, "HelloWorld" is segmented `Hello|World` whereas "XMLHttpRequest" is |
| 21 |
segmented `XML|Http|Request`. |
| 22 |
|
| 23 |
Characters not within words (such as spaces, punctuations, and underscores) |
| 24 |
are not included in the output string except as they are a part of the case |
| 25 |
being converted to. Multiple adjacent word boundaries (such as a series of |
| 26 |
underscores) are folded into one. ("hello__world" in snake case is therefore |
| 27 |
"hello_world", not the exact same string). Leading or trailing word boundary |
| 28 |
indicators are dropped, except insofar as CamelCase capitalizes the first word. |
| 29 |
|
| 30 |
## Cases contained in this library: |
| 31 |
|
| 32 |
1. UpperCamelCase |
| 33 |
2. lowerCamelCase |
| 34 |
3. snake_case |
| 35 |
4. kebab-case |
| 36 |
5. SHOUTY_SNAKE_CASE |
| 37 |
6. Title Case |
| 38 |
7. SHOUTY-KEBAB-CASE |
| 39 |
8. Train-Case |
| 40 |
|
| 41 |
## MSRV |
| 42 |
|
| 43 |
The minimum supported Rust version for this crate is 1.56.0. This may change in |
| 44 |
minor or patch releases, but we probably won't ever require a very recent |
| 45 |
version. If you would like to have a stronger guarantee than that, please open |
| 46 |
an issue. |
| 47 |
|
| 48 |
## License |
| 49 |
|
| 50 |
heck is distributed under the terms of both the MIT license and the |
| 51 |
Apache License (Version 2.0). |
| 52 |
|
| 53 |
See LICENSE-APACHE and LICENSE-MIT for details. |