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

broken_link_callback removed support for closures borrowing from their context #496

Closed
kornelski opened this issue Dec 4, 2024 · 2 comments · Fixed by #499
Closed

broken_link_callback removed support for closures borrowing from their context #496

kornelski opened this issue Dec 4, 2024 · 2 comments · Fixed by #499

Comments

@kornelski
Copy link
Contributor

In #484 the change made the callback require 'static lifetime, because Arc has an implicit + 'static bound.

This means that closures which borrow from their environment are forbidden now, and must be made to own all of their state. This is especially difficult to use comrak in methods that take &self and need to call self.some_lookup_method() when fixing links.

The same problem still exists when implementing the BrokenLinkCallback trait, since Arc<dyn BrokenLinkCallback> is always going to require 'static for every implementation.

I suggest changing it to Arc<dyn BrokenLinkCallback + 'c> and restoring the 'c lifetime on options.

@kivikakk
Copy link
Owner

kivikakk commented Dec 5, 2024

Hi, thanks for this report! I will loop in @liamwhite here— it seems like we might want to partly revert #484 to permit this.

@kivikakk
Copy link
Owner

kivikakk commented Dec 7, 2024

Thank you for the report — this was addressed in #499!

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 a pull request may close this issue.

2 participants