Crates.io | casey |
lib.rs | casey |
version | |
source | src |
created_at | 2019-05-01 05:51:27.584072 |
updated_at | 2024-12-28 03:11:00.683235 |
description | Case transforming macros for ident tokens |
homepage | |
repository | https://github.com/jordy25519/casey |
max_upload_size | |
id | 131312 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Case transforming macros
Casey transforms the case of given input ident
s.
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`
Casey macros can operate on TokenStream
s 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).
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;`