Sha256: 0094b318caf5771cc2308b38b9c8d3d1e836df72b79bb3c77f84dc9f553f8b84
Contents?: true
Size: 579 Bytes
Versions: 4
Compression:
Stored size: 579 Bytes
Contents
use magnus::{block::Proc, eval, value::Opaque, Ruby, Value}; fn make_proc(ruby: &Ruby) -> Proc { let x = String::from("foo"); let y = Opaque::from(ruby.str_new("bar")); ruby.proc_from_fn(move |_ruby, _args, _block| Ok((x.clone(), y))) } #[test] fn proc_from_closure_can_be_called_later() { let ruby = unsafe { magnus::embed::init() }; let proc = make_proc(&ruby); eval::<Value>(r#"1024.times.map {|i| "test#{i}"}"#).unwrap(); ruby.gc_start(); let res: bool = eval!(ruby, r#"proc.call == ["foo", "bar"]"#, proc).unwrap(); assert!(res); }
Version data entries
4 entries across 4 versions & 1 rubygems