magnus 0.9.2

High level Ruby bindings. Write Ruby extension gems in Rust, or call Ruby code from a Rust binary.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use magnus::{Ruby, function, rb_assert};

#[test]
fn it_makes_a_proc() {
    let ruby = unsafe { magnus::embed::init() };

    ruby.define_global_function("make_proc", function!(Ruby::block_proc, 0))
        .unwrap();

    rb_assert!(ruby, "Proc === make_proc { 1 + 1 }");
    rb_assert!(ruby, "(make_proc { 1 + 1 }).call == 2");
    rb_assert!(
        ruby,
        "begin; make_proc; rescue => e; end; ArgumentError === e"
    );
}