10 releases

0.4.2 Dec 28, 2024
0.4.1 Dec 28, 2024
0.4.0 May 15, 2023
0.3.3 Oct 6, 2020
0.1.1 May 7, 2019

#174 in Procedural macros

Download history 2404/week @ 2024-09-30 1951/week @ 2024-10-07 2638/week @ 2024-10-14 2659/week @ 2024-10-21 2510/week @ 2024-10-28 2701/week @ 2024-11-04 3463/week @ 2024-11-11 3548/week @ 2024-11-18 3934/week @ 2024-11-25 2886/week @ 2024-12-02 3864/week @ 2024-12-09 3783/week @ 2024-12-16 2428/week @ 2024-12-23 2028/week @ 2024-12-30 3185/week @ 2025-01-06 3326/week @ 2025-01-13

11,183 downloads per month
Used in 35 crates (15 directly)

MIT license

10KB
173 lines

Casey

Build

Case transforming macros

Casey transforms the case of given input idents.
Niche but maybe useful in other macros.

use casey::{pascal, lower, shouty, snake, upper};

lower!(ABC);    // renders: `abc`
upper!(abc);    // `ABC`
snake!(ABC);    // `a_b_c`
pascal!(ab_c);  // `AbC`
shouty!(a_b_c); // `A_B_C`

Token Stream

Casey macros can operate on TokenStreams e.g.

    snake!(
        #[derive(PartialEq)]
        struct MockStruct {}
        impl MockStruct {
            fn test() -> bool { true }
        }
    );
    assert!(mock_struct::test());
    assert!(mock_struct::test() == mock_struct::test())

All ident tokens in the stream will have the case transformation applied (keywords and attribute macros will be ignored).

Gotchas

Type names, including built-in types are not considered keywords e.g. bool, usize, i32 etc. and will be transformed by casey.

pascal!(let test: bool = true); // renders: `let Test: Bool = true;`

Dependencies

~225–660KB
~16K SLoC