diff --git a/src/value.rs b/src/value.rs index 9ae777d..4cca507 100644 --- a/src/value.rs +++ b/src/value.rs @@ -109,6 +109,20 @@ impl<'a, T> OCaml<'a, T> { { RustT::from_ocaml(*self) } + + /// Meant to match Data_custom_val from mlvalues.h + /// + /// # Safety + /// + /// Casts to an arbitrary pointer type, take care before + /// dereferencing + /// + /// Similar to raw(), the resulting pointer can become invalid + /// after any call into the OCaml runtime, for example allocating + /// OCaml values or calling OCaml functions + pub unsafe fn custom_ptr_val(&self) -> *const U { + ocaml_sys::field(self.raw, 1) as *const U + } } impl OCaml<'static, ()> {