Skip to content

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

Merged
TedDriggs merged 1 commit into
TedDriggs:masterfrom
sunshowers:cb
Jul 17, 2020
Merged

Add a way to run a callback on file load#16
TedDriggs merged 1 commit into
TedDriggs:masterfrom
sunshowers:cb

Conversation

@sunshowers

Copy link
Copy Markdown
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.

Comment thread 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
Copy Markdown
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
Copy Markdown
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.

2 participants