casey

Crates.iocasey
lib.rscasey
version0.4.0
sourcesrc
created_at2019-05-01 05:51:27.584072
updated_at2023-05-15 02:02:11.018277
descriptionCase transforming macros for ident tokens
homepage
repositoryhttps://github.com/jordy25519/casey
max_upload_size
id131312
size14,447
(jordy25519)

documentation

README

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;`
Commit count: 28

cargo fmt