Skip to main content

run

Function run 

Source
pub fn run(
    source: &str,
    entry: Option<&str>,
    registry: Rc<Registry>,
) -> Result<Value, Vec<LiveError>>
Expand description

Runs the function entry of source, or its first function, with no arguments.

let registry = std::rc::Rc::new(ravenrs_live::Registry::new());
let value = ravenrs_live::run(
    "fn total() -> i64 { (1..=4).map(|n| n * n).sum() }",
    None,
    registry,
)
.map_err(|e| e[0].to_string())?;
assert_eq!(value, ravenrs_live::Value::Int(30));