How push new ObjectProperty to program AST in Rust #7899
Unanswered
shahryarjb
asked this question in
Q&A
Replies: 1 comment 1 reply
-
It should be |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi friends, I need help adding an empty object to a key, like "hooks," in Rust. I've been stuck on this for three days due to my limited knowledge as a Rust beginner.
Please take a look at the function below. Ignore most of the code except for the last few lines, where I'm trying to add an empty object I've created to the existing ast.
I mean this line:
iter.push(new_hooks_property)
. However, iter doesn’t support push here. I've tried several other approaches, but unfortunately, I keep running into errors, including lifetime issues and more.magine what I’m trying to do is as follows:
In a JavaScript file, we have lines like this:
I want to check if the
liveSocket
variable contains ahooks
key. If it doesn’t, I want to add one with an empty object, so it becomes:If hooks already exists, I don’t need to do anything and just return it as is.
This is the entire function I've written for this simple task, but unfortunately, I haven't been able to complete it. I thought perhaps I could use your help:
https://github.com/shahryarjb/mishka_chelekom/blob/a3ae62b8b1eaca5fbe66ed66bfc00c3be29e24a3/native/mishka_parser_nif/src/parser/ast.rs#L170-L324
Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions