Memory representation guarantees and Obj.magic

:man_facepalming: :man_facepalming: :man_facepalming:
Of course this works. Well the problem is solved! I do have to write an mli by hand but I guess it’s good practice anyway

That being said, I’m still interested in the answer. Thanks to @sim642 I also used the keywords “part of the language” when googling and found this answer. I guess OCaml cannot provide any guarantee about Obj.magic because it also doesn’t provide any guarantee about the memory layout of things… But for unboxing a type I would expect some guarantees? Rust does give guarantees about std::mem::transmute, even though these guarantees aren’t really strong. But they do apply specifically to things like #[repr(transparent)] which has the exact same behaviour as [@@unboxed]