paste
paste copied to clipboard
Snake case preserving `/` (slash) characters
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.
I have the same problem now: needing to convert a path string to a valid Rust identifier.