Macro const_str::convert_ascii_case
source · [−]macro_rules! convert_ascii_case {
(lower, $s: expr) => { ... };
(upper, $s: expr) => { ... };
(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!(camel, "camel case");
const S4: &str = convert_ascii_case!(snake, "snake case");
const S5: &str = convert_ascii_case!(kebab, "kebab case");
const S6: &str = convert_ascii_case!(shouty_snake, "shouty snake case");
const S7: &str = convert_ascii_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");