rusty_v8, how to mutate scope outside anonymous function
Hi, I'm trying to use the v8 rust create to run javascript on my backend and now I'm stuck at how to modify a
Vec<String>
declared outside a anonymous function scope, as said function gets used to be the callback of a v8::Function
.
The errors I'm getting are the following:
Please be aware that I'm still very new to Rust so extra insights into what's going wrong here would be very helpful!2 Replies
For the
logs
vector, you need to wrap it in Rc
and RefCell
:
https://stackoverflow.com/questions/52994205/what-is-the-standard-way-to-call-a-mutable-method-in-a-rc-wrapped-object
As for the v8 thing, I've not try it myself.Stack Overflow
What is the standard way to call a mutable method in a Rc-wrapped o...
In the following code, I am trying to change the value of a refcounted object by calling one of its methods:
use std::rc::Rc;
fn main() {
let mut x = Rc::new(Thing { num: 50 });
x.
For the function error, you actually can't use closure because the type
impl MapFnTo<FunctionCallback>
doesn't allow to. Closure is when you use external var inside the |arg| {}
form.
See this playground.