Storing an Arena<AstNode<'_>> in a struct
#356
Unanswered
nic-hartley
asked this question in
Q&A
Replies: 2 comments 10 replies
|
This should be a lifetime parameter of your struct (that's usual rust stuff): struct SiteGenerator<'ast> {
arena: Arena<AstNode<'ast>>,
// ...
} |
5 replies
|
I experienced a similar challenge writing a markdown editor. I make an arena with: let arena = Arena::new();then I parse my document and get my root node with: let root = comrak::parse_document(&arena, &text, &options);but since Ultimately, since my app is immediate mode, I just allocate a new arena re-parse the document every frame. Last I checked we could render a 750kb markdown document at 90fps and markdown parsing was not a significant portion of our CPU time. So, I'm not experiencing an issue, but the question makes sense to me 👍🏻 |
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello! I'm trying to make something to the effect of:
Cannot for the life of me figure out what the
'??should be, or lifetimes in return types, etc. (I tried adding a lifetime parameter, but predictably that didn't work; after all, the lifetime here isn't a parameter, it's the lifetime of the struct.) One option would be creating the arena externally and storing a&'a Arena<AstNode<'a>>, but that's... annoying? And I feel like there's a better way.All reactions