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

Derives Custom with the given finalizer for a type

use ocaml::FromValue;

struct MyType {
    name: String
}

// NOTE: this is the default finalizer, no need to write this in
// your own code
unsafe extern "C" fn mytype_finalizer(v: ocaml::Raw) {
    let p = v.as_pointer::<MyType>();
    p.drop_in_place();
}

ocaml::custom_finalize!(MyType, mytype_finalizer);

// Which is a shortcut for:

struct MyType2 {
    name: String
}

unsafe extern "C" fn mytype2_finalizer(v: ocaml::Raw) {
    let p = v.as_pointer::<MyType>();
    p.drop_in_place()
}

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