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

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/typed_data.rs
wasmtime-28.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/typed_data.rs
wasmtime-27.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/typed_data.rs
wasmtime-26.0.0 ./ext/cargo-vendor/magnus-0.7.1/tests/typed_data.rs
wasmtime-25.0.2 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-25.0.1 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-25.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-24.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-23.0.2 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-22.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-21.0.1 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-20.0.2 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-20.0.0 ./ext/cargo-vendor/magnus-0.6.4/tests/typed_data.rs
wasmtime-18.0.3 ./ext/cargo-vendor/magnus-0.6.2/tests/typed_data.rs
wasmtime-17.0.1 ./ext/cargo-vendor/magnus-0.6.2/tests/typed_data.rs
wasmtime-17.0.0 ./ext/cargo-vendor/magnus-0.6.2/tests/typed_data.rs
wasmtime-16.0.0 ./ext/cargo-vendor/magnus-0.6.2/tests/typed_data.rs
wasmtime-15.0.1 ./ext/cargo-vendor/magnus-0.6.2/tests/typed_data.rs
wasmtime-15.0.0 ./ext/cargo-vendor/magnus-0.6.2/tests/typed_data.rs