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.

Limitations

  • Building is delegated to rustc.
  • rustc needs to be in the PATH.
  • It is slow.
  • External crates are not supported.

Examples

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