Function everust::eval [] [src]

pub fn eval(code: &str) -> Result<String, EvalError>

Evaluates rust code.

The code is implicitly enclosed in braces to make it an expression. The type of the expression must be Debug. If successful, the result of the evaluation is formatted with Debug and returned.

Errors

If the evaluation fails because of a build error, the returned error value can be formatted with Display to inspect the build errors.

Examples

use everust::eval;
assert_eq!("2", eval("let n = 1; n + 1").unwrap());