[][src]Macro ocaml::custom_finalize

macro_rules! custom_finalize {
    ($name:ident  $(<$t:tt>)?, $f:path) => { ... };
}

Derives Custom with the given finalizer for a type

use ocaml::FromValue;

struct MyType {
    name: String
}

unsafe extern "C" fn mytype_finalizer(v: ocaml::Value) {
    let p: ocaml::Pointer<MyType> = ocaml::Pointer::from_value(v);
    p.drop_in_place()
}

ocaml::custom_finalize!(MyType, mytype_finalizer);

// Which is a shortcut for:

struct MyType2 {
    name: String
}

ocaml::custom!(MyType2 {
    finalize: mytype_finalizer
});