1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
pub use const_str_proc_macro::convert_case;

macro_rules! convert_case_doc {
    () => {
        r#"
Converts a string literal to a specified case.

These variants require the feature `case`.

+ lower_camel
+ upper_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");
# #[cfg(feature = "case")]
const S3: &str = convert_case!(lower_camel, "lower camel case");
# #[cfg(feature = "case")]
const S4: &str = convert_case!(upper_camel, "upper camel case");
# #[cfg(feature = "case")]
const S5: &str = convert_case!(snake, "snake case");
# #[cfg(feature = "case")]
const S6: &str = convert_case!(kebab, "kebab case");
# #[cfg(feature = "case")]
const S7: &str = convert_case!(shouty_snake, "shouty snake case");
# #[cfg(feature = "case")]
const S8: &str = convert_case!(shouty_kebab, "shouty kebab case");

assert_eq!(S1, "lower case");
assert_eq!(S2, "UPPER CASE");
# #[cfg(feature = "case")]
assert_eq!(S3, "lowerCamelCase");
# #[cfg(feature = "case")]
assert_eq!(S4, "UpperCamelCase");
# #[cfg(feature = "case")]
assert_eq!(S5, "snake_case");
# #[cfg(feature = "case")]
assert_eq!(S6, "kebab-case");
# #[cfg(feature = "case")]
assert_eq!(S7, "SHOUTY_SNAKE_CASE");
# #[cfg(feature = "case")]
assert_eq!(S8, "SHOUTY-KEBAB-CASE");
```
"#
    };
}

#[doc = convert_case_doc!() ] // stable since 1.54
#[cfg(not(feature = "case"))]
#[macro_export]
macro_rules! convert_case {
    (lower, $s: literal) => {
        $crate::__proc::convert_case!(lower, $s)
    };
    (upper, $s: literal) => {
        $crate::__proc::convert_case!(upper, $s)
    };
}

#[cfg_attr(docsrs, doc(cfg(any(feature = "proc", feature = "case"))))]
#[doc = convert_case_doc!() ] // stable since 1.54
#[cfg(feature = "case")]
#[macro_export]
macro_rules! convert_case {
    (lower, $s: literal) => {
        $crate::__proc::convert_case!(lower, $s)
    };
    (upper, $s: literal) => {
        $crate::__proc::convert_case!(upper, $s)
    };
    (lower_camel, $s: literal) => {
        $crate::__proc::convert_case!(lower_camel, $s)
    };
    (upper_camel, $s: literal) => {
        $crate::__proc::convert_case!(upper_camel, $s)
    };
    (snake, $s: literal) => {
        $crate::__proc::convert_case!(snake, $s)
    };
    (kebab, $s: literal) => {
        $crate::__proc::convert_case!(kebab, $s)
    };
    (shouty_snake, $s: literal) => {
        $crate::__proc::convert_case!(shouty_snake, $s)
    };
    (shouty_kebab, $s: literal) => {
        $crate::__proc::convert_case!(shouty_kebab, $s)
    };
}