Skip to content

Commit

Permalink
Remove Case::ScreamingSnake, add Case::Constant
Browse files Browse the repository at this point in the history
  • Loading branch information
rutrum committed Dec 17, 2024
1 parent 8f2dc79 commit 89727ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This is list of cases that convert\_case supports. Some cases are simply aliase
| Camel | myVariableName |
| Pascal<br />UpperCamel | MyVariableName |
| Snake | my\_variable\_name |
| UpperSnake<br />ScreamingSnake | MY\_VARIABLE\_NAME |
| Constant <br />UpperSnake | MY\_VARIABLE\_NAME |
| Kebab | my-variable-name |
| Cobol | MY-VARIABLE-NAME |
| Train | My-Variable-Name |
Expand All @@ -62,6 +62,8 @@ This is list of cases that convert\_case supports. Some cases are simply aliase
| Random | MY vaRiabLe nAME |
| PseudoRandom | mY VaRiAblE nAMe |

## License
## Change Log

Licensed under [MIT License](./LICENSE).
### 0.7.0

* Replace `Case::ScreamingSnake` with `Case::Constant`.
27 changes: 14 additions & 13 deletions src/case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ pub enum Case {
/// ```
Snake,

/// Upper snake case strings are delimited by underscores `_` and are all uppercase.
/// Constant case strings are delimited by underscores `_` and are all uppercase.
/// * Boundaries: [Underscore](Boundary::Underscore)
/// * Pattern: [Uppercase](Pattern::Uppercase)
/// * Delimeter: Underscore `_`
///
/// ```
/// use convert_case::{Case, Casing};
/// assert_eq!("MY_VARIABLE_NAME", "My variable NAME".to_case(Case::UpperSnake))
/// assert_eq!("MY_VARIABLE_NAME", "My variable NAME".to_case(Case::Constant))
/// ```
UpperSnake,
Constant,

/// Screaming snake case is an alternative name for [upper snake case](Case::UpperSnake).
ScreamingSnake,
/// Upper snake case is an alternative name for [constant case](Case::Constant).
UpperSnake,

/// Kebab case strings are delimited by hyphens `-` and are all lowercase.
/// * Boundaries: [Hyphen](Boundary::Hyphen)
Expand Down Expand Up @@ -244,14 +244,14 @@ impl Case {
/// | Cases | Delimeter |
/// | --- | --- |
/// | Upper, Lower, Title, Toggle, Alternating, Random, PseudoRandom | Space |
/// | Snake, UpperSnake, ScreamingSnake | Underscore `_` |
/// | Snake, Constant, UpperSnake | Underscore `_` |
/// | Kebab, Cobol, UpperKebab, Train | Hyphen `-` |
/// | UpperFlat, Flat, Camel, UpperCamel, Pascal | Empty string, no delimeter |
pub const fn delim(&self) -> &'static str {
use Case::*;
match self {
Upper | Lower | Title | Toggle | Alternating => " ",
Snake | UpperSnake | ScreamingSnake => "_",
Snake | Constant | UpperSnake => "_",
Kebab | Cobol | UpperKebab | Train => "-",

#[cfg(feature = "random")]
Expand All @@ -266,7 +266,7 @@ impl Case {
///
/// | Cases | Pattern |
/// | --- | --- |
/// | Upper, UpperSnake, ScreamingSnake, UpperFlat, Cobol, UpperKebab | Uppercase |
/// | Upper, Constant, UpperSnake, UpperFlat, Cobol, UpperKebab | Uppercase |
/// | Lower, Snake, Kebab, Flat | Lowercase |
/// | Title, Pascal, UpperCamel, Train | Capital |
/// | Camel | Camel |
Expand All @@ -276,7 +276,7 @@ impl Case {
pub const fn pattern(&self) -> Pattern {
use Case::*;
match self {
Upper | UpperSnake | ScreamingSnake | UpperFlat | Cobol | UpperKebab => {
Upper | Constant | UpperSnake | UpperFlat | Cobol | UpperKebab => {
Pattern::Uppercase
}
Lower | Snake | Kebab | Flat => Pattern::Lowercase,
Expand All @@ -299,7 +299,7 @@ impl Case {
/// | Cases | Boundaries |
/// | --- | --- |
/// | Upper, Lower, Title, Toggle, Alternating, Random, PseudoRandom | Space |
/// | Snake, UpperSnake, ScreamingSnake | Underscore `_` |
/// | Snake, Constant, UpperSnake | Underscore `_` |
/// | Kebab, Cobol, UpperKebab, Train | Hyphen `-` |
/// | Camel, UpperCamel, Pascal | LowerUpper, LowerDigit, UpperDigit, DigitLower, DigitUpper, Acronym |
/// | UpperFlat, Flat | No boundaries |
Expand All @@ -308,7 +308,7 @@ impl Case {
use Case::*;
match self {
Upper | Lower | Title | Toggle | Alternating => vec![Space],
Snake | UpperSnake | ScreamingSnake => vec![Underscore],
Snake | Constant | UpperSnake => vec![Underscore],
Kebab | Cobol | UpperKebab | Train => vec![Hyphen],

#[cfg(feature = "random")]
Expand All @@ -323,6 +323,7 @@ impl Case {

// Created to avoid using the EnumIter trait from strum in
// final library. A test confirms that all cases are listed here.
// Why is this needed? If it's only for ccase then I don't see why it's here.
/// Returns a vector with all case enum variants in no particular order.
pub fn all_cases() -> Vec<Case> {
use Case::*;
Expand All @@ -335,8 +336,8 @@ impl Case {
Pascal,
UpperCamel,
Snake,
Constant,
UpperSnake,
ScreamingSnake,
Kebab,
Cobol,
UpperKebab,
Expand Down Expand Up @@ -372,8 +373,8 @@ impl Case {
Pascal,
UpperCamel,
Snake,
Constant,
UpperSnake,
ScreamingSnake,
Kebab,
Cobol,
UpperKebab,
Expand Down

0 comments on commit 89727ba

Please sign in to comment.