Function rustyscript::evaluate

source ·
pub fn evaluate<T>(javascript: &str) -> Result<T, Error>
Expand description

Evaluate a piece of non-ECMAScript-module JavaScript code Effects on the global scope will not persist For a persistant variant, see Runtime::eval

§Arguments

  • javascript - A single javascript expression

§Returns

A Result containing the deserialized result of the expression if successful, or an error if execution fails, or the result cannot be deserialized.

§Example

let result: i64 = rustyscript::evaluate("5 + 5").expect("The expression was invalid!");
assert_eq!(10, result);