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

Remove .unwrap() in detach() #35

Open
ronanM opened this issue Sep 22, 2024 · 1 comment
Open

Remove .unwrap() in detach() #35

ronanM opened this issue Sep 22, 2024 · 1 comment
Assignees
Labels

Comments

@ronanM
Copy link

ronanM commented Sep 22, 2024

In a web crawler, when I strip the HTML tree, sometimes detach() panic on the .unwrap().

@LoZack19
Copy link
Contributor

LoZack19 commented Oct 9, 2024

Detatch panics in three situations:

  1. If its parent doesn't have any children (impossible)
  2. If it's the first and not only child of its parent, but it doesn't have a next sibling (impossible)
  3. If it's the last and not only child of its parent, but it doesn't have a previous sibling (impossible)

If detach went wrong, you must have a malformed tree. Could you point out which line of the detach method causes panic? I would also like a debug print of the tree you're using, in order to understand what is going wrong. If you provide us with more information, we could try to understand what part of the source code is failing.

Removing the unwrap isn't a solution, because if detatch fails, it means that there's something very wrong going on with the tree, and we must fix it. Some invariants must not be respected for this to happen.

@LoZack19 LoZack19 added the bug label Oct 9, 2024
@LoZack19 LoZack19 self-assigned this Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants