Crates.io | mruby-eval |
lib.rs | mruby-eval |
version | 0.1.0 |
source | src |
created_at | 2021-10-06 08:50:36.414148 |
updated_at | 2021-10-06 08:50:36.414148 |
description | A package to execute ruby code trough mruby bindings |
homepage | |
repository | https://github.com/DumbMahreeo/mruby-eval |
max_upload_size | |
id | 461044 |
size | 5,146 |
This is a package I made for another lib, but here's how to use it:
use mruby-eval::{eval_to, evaluators::eval_to_string};
eval_to_string("1+2") // returns an Option<String>, in this case Some(String::from("3"))
eval_to!(i32, "1+2") // eval_to!<type, expr> returns an Err<type, Parse#Error>
// (# in ParseError is the type, ex: ParseIntError)
//
// So in this case it's Ok(3)