Macro ocaml::custom_finalize
source · [−]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
}
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
}
ocaml::custom!(MyType2 {
finalize: mytype_finalizer
});