Skip to content

Add Raw Mode in paste! macro to allow generating Raw Identifiers#8

Merged
AS1100K merged 6 commits intomasterfrom
keyword
Mar 12, 2025
Merged

Add Raw Mode in paste! macro to allow generating Raw Identifiers#8
AS1100K merged 6 commits intomasterfrom
keyword

Conversation

@AS1100K
Copy link
Copy Markdown
Owner

@AS1100K AS1100K commented Mar 10, 2025

  • Update README.md

Fixes #7

This PR adds Raw mode to the paste! macro. The following syntax can generate raw identifiers:

use pastey::paste;

macro_rules! m{
    ($name:ident $(- $name_tail:ident)*) => {
        paste!{
            struct [< # $name:camel $( $name_tail)* >];

            impl [< # $name:camel $( $name_tail)* >] {
                fn [< # $name:snake $( _ $name_tail:snake)* >]() {}
            }

        }
    }
}

m!(loop);
m!(loop - xyz);

#[test]
fn test_fn() {
    let _ = Loop::r#loop();
    let _ = Loopxyz::loop_xyz();
}

Concerns

I am not entirely sure that I would go with having # as the keyword to enable raw mode

@AS1100K AS1100K requested a review from Copilot March 10, 2025 16:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@AS1100K AS1100K requested a review from Copilot March 10, 2025 16:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@AS1100K AS1100K added the enhancement New feature or request label Mar 10, 2025
@AS1100K AS1100K merged commit 8553962 into master Mar 12, 2025
17 checks passed
@AS1100K AS1100K deleted the keyword branch March 12, 2025 04:29
@AS1100K AS1100K mentioned this pull request Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paste sometimes produces keywords

2 participants