#language #programming-language #wren #programs #embed

nightly wren-rs

Embed the Wren programming language in your Rust program

1 unstable release

Uses old Rust 2015

0.1.0 Jan 6, 2015

#1108 in Programming languages

MIT license

4KB
74 lines

Wren for Rust

You can use this library to interpret Wren code in your Rust programs.

Use

extern crate wren;

use std::default::Default;

use wren::{VM, Error};

fn main() {
    let source = r#"
class Unicorn {
  hasHorn {
    return true
  }
}
"#;
    let vm = VM::new(Default::default()); // loads the VM with the default VM config
    match vm.interpret("Test", source) {
      Err(Error::CompileError(msg)) => println!("Compile Error: {}", msg),
      Err(Error::RuntimeError(msg)) => println!("Runtime Error: {}", msg),
      Err(Error::UnknownError(msg)) => println!("Unknown Error: {}", msg),
      _ => println!("Successfully ran wren source"),
    }
}

Dependencies