macro_rules! convert_case {
    (lower, $s: literal) => { ... };
    (upper, $s: literal) => { ... };
    (camel, $s: literal) => { ... };
    (snake, $s: literal) => { ... };
    (kebab, $s: literal) => { ... };
    (shouty_snake, $s: literal) => { ... };
    (shouty_kebab, $s: literal) => { ... };
}
Expand description

Converts a string literal to a specified case.

These variants require the feature case.

  • camel
  • kebab
  • snake
  • shouty_snake
  • shouty_kebab

Examples

use const_str::convert_case;

const S1: &str = convert_case!(lower, "Lower Case");
const S2: &str = convert_case!(upper, "Upper Case");
const S3: &str = convert_case!(camel, "camel case");
const S4: &str = convert_case!(snake, "snake case");
const S5: &str = convert_case!(kebab, "kebab case");
const S6: &str = convert_case!(shouty_snake, "shouty snake case");
const S7: &str = convert_case!(shouty_kebab, "shouty kebab case");

assert_eq!(S1, "lower case");
assert_eq!(S2, "UPPER CASE");
assert_eq!(S3, "CamelCase");
assert_eq!(S4, "snake_case");
assert_eq!(S5, "kebab-case");
assert_eq!(S6, "SHOUTY_SNAKE_CASE");
assert_eq!(S7, "SHOUTY-KEBAB-CASE");