Function run_script_main_thread_int

Source
pub fn run_script_main_thread_int<T>(script: T) -> c_int
where T: AsRef<str>,
Expand description

Runs the given JavaScript script string with the eval() JS function, in the main thread, using the emscripten-defined MAIN_THREAD_EM_ASM_INT. It returns the return result of the script, interpreted as a C int. Most probably the return result is passed to parseInt(), with NaN represented as 0.

If you need to run the script in the calling thread, check out run_script_int.

§Arguments

  • script - The script to execute.

§Examples

assert_eq!(run_script_main_thread_int("1 + 2"), 3);