[][src]Macro ocaml_interop::to_ocaml

macro_rules! to_ocaml {
    ($cr:ident, $obj:expr, $rootvar:ident) => { ... };
    ($cr:ident, $obj:expr) => { ... };
    ($($t:tt)*) => { ... };
}

Converts Rust values into OCaml values.

In to_ocaml!(cr, value), cr is an OCaml Runtime handle, and value is a Rust value of a type that implements the ToOCaml trait. The resulting value's lifetime is bound to cr's borrow.

An alternative form accepts a third "root variable" argument: to_ocaml!(cr, value, rootvar). rootvar is one of the "root variables" declared when opening an ocaml_frame!. This variant consumes rootvar returns an OCamlRef value instead of an OCaml one.

Examples

    let ocaml_string: OCaml<String> = to_ocaml!(cr, "hello OCaml!");
    // ...

Variant:

    ocaml_frame!(cr, (rootvar), {
        let ocaml_string_ref: OCamlRef<String> = to_ocaml!(cr, "hello OCaml!", rootvar);
        // ...
    });