macro_rules! convert_ascii_case {
    (lower, $s: expr) => { ... };
    (upper, $s: expr) => { ... };
    (lower_camel, $s: expr) => { ... };
    (upper_camel, $s: expr) => { ... };
    (snake, $s: expr) => { ... };
    (kebab, $s: expr) => { ... };
    (shouty_snake, $s: expr) => { ... };
    (shouty_kebab, $s: expr) => { ... };
}
Expand description

Converts a string slice to a specified case. Non-ascii characters are not affected.

§Examples

use const_str::convert_ascii_case;

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

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