diff options
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Cargo.toml | 4 | ||||
-rw-r--r-- | Cargo.toml.orig | 4 | ||||
-rw-r--r-- | METADATA | 4 | ||||
-rw-r--r-- | src/lib.rs | 5 | ||||
-rw-r--r-- | tests/test.rs | 30 |
6 files changed, 40 insertions, 9 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 28d7b30..652f708 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "5feb37605c9ec2d237651dbd669e3527566a839e" + "sha1": "a3c7d4f0d396480243fd40b777bd3708e87ea80c" } } @@ -13,7 +13,7 @@ [package] edition = "2018" name = "paste" -version = "0.1.10" +version = "0.1.11" authors = ["David Tolnay <dtolnay@gmail.com>"] description = "Macros for all your token pasting needs" readme = "README.md" @@ -22,7 +22,7 @@ repository = "https://github.com/dtolnay/paste" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies.paste-impl] -version = "=0.1.10" +version = "=0.1.11" [dependencies.proc-macro-hack] version = "0.5.9" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 6f0d704..285cd55 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "paste" -version = "0.1.10" +version = "0.1.11" authors = ["David Tolnay <dtolnay@gmail.com>"] edition = "2018" license = "MIT OR Apache-2.0" @@ -12,7 +12,7 @@ readme = "README.md" travis-ci = { repository = "dtolnay/paste" } [dependencies] -paste-impl = { version = "=0.1.10", path = "impl" } +paste-impl = { version = "=0.1.11", path = "impl" } proc-macro-hack = "0.5.9" [dev-dependencies] @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/dtolnay/paste" } - version: "0.1.10" + version: "0.1.11" license_type: NOTICE last_upgrade_date { year: 2020 month: 4 - day: 17 + day: 27 } } @@ -117,8 +117,9 @@ //! example, `[<ld_ $reg:lower _expr>]` would paste to `ld_bc_expr` if invoked //! with $reg=`Bc`. //! -//! Use `$var:snake` to convert CamelCase input to snake\_case. These compose, -//! so for example `$var:snake:upper` would give you SCREAMING\_CASE. +//! Use `$var:snake` to convert CamelCase input to snake\_case. +//! Use `$var:camel` to convert snake\_case to CamelCase. +//! These compose, so for example `$var:snake:upper` would give you SCREAMING\_CASE. //! //! The precise Unicode conversions are as defined by [`str::to_lowercase`] and //! [`str::to_uppercase`]. diff --git a/tests/test.rs b/tests/test.rs index 435eb71..e281c92 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -255,3 +255,33 @@ fn test_env_to_snake() { let _ = LIBPASTE; } } + +mod test_to_camel { + macro_rules! m { + ($id:ident) => { + paste::item! { + const DEFAULT_CAMEL: &str = stringify!([<$id:camel>]); + const LOWER_CAMEL: &str = stringify!([<$id:camel:lower>]); + const UPPER_CAMEL: &str = stringify!([<$id:camel:upper>]); + } + }; + } + + m!(this_is_but_a_test); + + #[test] + fn test_to_camel() { + assert_eq!(DEFAULT_CAMEL, "ThisIsButATest"); + assert_eq!(LOWER_CAMEL, "thisisbutatest"); + assert_eq!(UPPER_CAMEL, "THISISBUTATEST"); + } +} + +#[test] +fn test_env_to_camel() { + paste::expr! { + const [<LIB env!("CARGO_PKG_NAME"):camel>]: &str = "libpaste"; + + let _ = LIBPaste; + } +} |