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

Consider providing a parse_file_with function to support shebang-handling in preprocessors #1781

Open
dfoxfranke opened this issue Nov 12, 2024 · 0 comments

Comments

@dfoxfranke
Copy link

dfoxfranke commented Nov 12, 2024

It would be useful to have a function available with a signature of

fn parse_file_with<T, F>(content: &str, parse: F) -> (Option<String>, Result<T>)
    where 
        T: Parse,
        F: FnOnce(&str) -> Result<T>;

I'm using syn to implement a preprocessor which outputs Rust code (and needs to do some things that are hard to do with proc macros), and want it to handle shebangs the same way that Rust does. Lacking a function like the one above, this requires me to make a wholesale copy of syn's private whitespace module and an almost-wholesale copy of parse_file. Having it available would let me avoid such code duplication.

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

1 participant