Lifetime Issues in UserData #495
-
I'm working on creating a scraper wrapper to enable Lua to support HTML parsing. My approach is straightforward: wrap the Html and the ElementRef. Below is a simplified version of my implementation:
wrap ElementRef<'a>:
I'm encountering some lifetime issues in this implementation. I've searched through past discussions and issues and found similar problems. But I'm unsure how to apply them in this situation. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You try to return an object that has reference to another object, which is not Instead, you need to use self-referential data structures to make the object refer to itself and be
then you can return |
Beta Was this translation helpful? Give feedback.
You try to return an object that has reference to another object, which is not
'static
, but Lua objects must be static since it does not have lifetimes.Instead, you need to use self-referential data structures to make the object refer to itself and be
'static
to meet the requirements. I would recommend ouroboros for that.If you define
HtmlElement
asthen you can return
HtmlElement
that can refer to inner (cheaply cloneable)root
.