Sha256: eec9de22f0bc8432540654557abbc217f431b1ba186dd81c7e92485d507ab095
Contents?: true
Size: 855 Bytes
Versions: 19
Compression:
Stored size: 855 Bytes
Contents
use magnus::RArray; #[test] fn can_get_slice_from_r_attay() { let ruby = unsafe { magnus::embed::init() }; let ary: RArray = ruby.eval(r#"[1, nil, "foo"]"#).unwrap(); let slice = unsafe { ary.as_slice() }; assert_eq!(3, slice.len()); assert_eq!("1", format!("{:?}", slice[0])); assert_eq!("nil", format!("{:?}", slice[1])); assert_eq!(r#""foo""#, format!("{:?}", slice[2])); let ary: RArray = ruby .eval(r#"["bar", "baz", 42, [1, 2, 3], :test]"#) .unwrap(); let slice = unsafe { ary.as_slice() }; assert_eq!(5, slice.len()); assert_eq!(r#""bar""#, format!("{:?}", slice[0])); assert_eq!(r#""baz""#, format!("{:?}", slice[1])); assert_eq!("42", format!("{:?}", slice[2])); assert_eq!("[1, 2, 3]", format!("{:?}", slice[3])); assert_eq!(":test", format!("{:?}", slice[4])); }
Version data entries
19 entries across 19 versions & 1 rubygems