Invoking rhai methods from rust

I want to invoke a method on a rhai Dynamic value. Specifically, I want to call to_debug. I'm currently doing this:

let ast = engine.compile(line)?;
    let mut val=engine.eval_ast_with_scope(scope,&ast)?;
    info!("val={val:?}");
    let debug=engine.call_fn_with_options::<String>(
        CallFnOptions::new().bind_this_ptr(&mut val),
        scope,
        &ast,
        "to_debug",()
    )?;

But I get

ErrorFunctionNotFound("to_debug", none)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.