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

Add a way to run a callback on file load #16

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

sunshowers
Copy link
Contributor

(This is based on #14.)

This is useful when integrating syn-inline-mod with other systems, as it allows
for file contents to be recorded for e.g. later error reporting.

This required some refactoring as we had to pass a &mut R down through the
visitor.

Included is a test which ensures that syn-inline-mod works on the crate itself.

src/lib.rs Outdated
/// recursively inlined.
pub fn parse_and_inline_modules(&self, src_file: &Path) -> Result<InliningResult, Error> {
self.parse_internal(src_file, FsResolver::default())
// Rust seems to not be able to resolve callback lifetimes properly with an inline
Copy link
Owner

Choose a reason for hiding this comment

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

I ran into this problem before; I think you have to pass it as &impl or something and then it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I couldn't figure out what you meant but it looked like simply annotating one of the arguments with the type worked fine.

This is useful when integrating syn-inline-mod with other systems, as it allows
for file contents to be recorded for e.g. later error reporting.

This required some refactoring as we had to pass a `&mut R` down through the
visitor.

Included is a test which ensures that syn-inline-mod works on the crate itself.
@TedDriggs TedDriggs merged commit f657c45 into TedDriggs:master Jul 17, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants