Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snake case preserving / (slash) characters #98

Open
brownjohnf opened this issue Aug 17, 2023 · 1 comment
Open

Snake case preserving / (slash) characters #98

brownjohnf opened this issue Aug 17, 2023 · 1 comment

Comments

@brownjohnf
Copy link

I'm attempting to use $expr:snake with a path containing slashes. My use-case is for automating tests, where test fixtures are in a hierarchical structure, and I'm auto-generating test modules based on the path I want to test:

mymacro!("some/file/path");

// I'd like this to expand to:
mod test_mymacro_some_file_path {..}

When using something like:

[< test_mymacro_ $expr:snake >]

it preserves the slash. I'm not sure what the expected/desired behavior is here; I see that the source explicitly only checks for case, not symbols, etc. Is there a way to achieve this with paste, or should I be doing something else, like using a $(path:ident)/+ pattern or something in my macro? I'm relatively new to writing macros, so apologies if I'm missing something obvious. This crate has been amazing for creating a robust test suite.

@ThinkerDreamer
Copy link

I have the same problem now: needing to convert a path string to a valid Rust identifier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants