Skip to content

Conversation

@ollpu
Copy link
Collaborator

@ollpu ollpu commented Jul 13, 2025

Edit: #1043 maybe doesn't need a new callback, so this PR doesn't need to be merged separately from #1013.


We want to use the same trait for other callbacks as well, e.g. as in #1013 #1043.

Since there will be more callbacks to override, it makes sense to remove the existing blanket implementation for closures. To keep backwards compatibility with most old use cases, new_with_broken_link_callback uses a new wrapper type.

I tried to move the 'input lifetime from the trait to the callbacks themselves, but I still ran into rust-lang/rust#41078 when trying to pass closures to new_with_broken_link_callback. I guess it's fine as is.

Breaking change, so I created a new release branch.

Remove blanket impl of ParserCallbacks for closures. Replaced with a
wrapper type BrokenLinkCallback to support the old API.
ollpu added a commit to ollpu/pulldown-cmark that referenced this pull request Sep 10, 2025
No measurable performance impact in a quick benchmark:
pulldown-cmark#1049 (comment)
@ollpu ollpu force-pushed the rename-parser-callbacks branch from b06e968 to b880cb7 Compare September 10, 2025 16:16
No measurable performance impact in a quick benchmark:
pulldown-cmark#1049 (comment)
@ollpu ollpu force-pushed the rename-parser-callbacks branch from b880cb7 to 9c7b81a Compare September 10, 2025 16:20
@ollpu ollpu requested a review from notriddle September 10, 2025 16:22
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