Sha256: 0a3104b3f1de5fd012a47532f78f23b066d425d5d8ed71625d25ea4d170c321c
Contents?: true
Size: 620 Bytes
Versions: 19
Compression:
Stored size: 620 Bytes
Contents
use magnus::{embed::init, eval, rb_assert, Ruby, Value}; #[magnus::wrap(class = "Example", free_immediately)] struct Example { value: String, } fn make_rb_example(ruby: &Ruby, value: &str) -> Value { let ex = Example { value: value.to_owned(), }; ruby.into_value(ex) } #[test] fn it_wraps_rust_struct() { let ruby = unsafe { init() }; ruby.define_class("Example", ruby.class_object()).unwrap(); let val = make_rb_example(&ruby, "foo"); rb_assert!(ruby, "val.class == Example", val); let ex: &Example = eval!(ruby, "val", val).unwrap(); assert_eq!("foo", ex.value) }
Version data entries
19 entries across 19 versions & 1 rubygems