diff --git a/src/conv/to_ocaml.rs b/src/conv/to_ocaml.rs
index 877a4bf..f49500b 100644
--- a/src/conv/to_ocaml.rs
+++ b/src/conv/to_ocaml.rs
@@ -250,3 +250,9 @@ where
})
}
}
+
+unsafe impl<'a, A> ToOCaml for OCaml<'a, A> {
+ fn to_ocaml(&self, _token: OCamlAllocToken) -> OCamlAllocResult {
+ OCamlAllocResult::of_ocaml(*self)
+ }
+}
diff --git a/src/value.rs b/src/value.rs
index 439d0ef..32189d3 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -10,12 +10,27 @@ use ocaml_sys::{caml_string_length, int_val, val_int};
/// Should not be instantiated directly, and will usually be the result
/// of [`ocaml_alloc!`] and [`ocaml_call!`] expressions, or the input arguments
/// of functions defined inside [`ocaml_export!`] blocks.
-#[derive(Copy, Clone)]
pub struct OCaml<'a, T: 'a> {
_marker: PhantomData<&'a T>,
raw: RawOCaml,
}
+// Trivial, manual implementation because the derive is overly conservative
+// and places bounds on type parameter T
+// https://github.com/rust-lang/rust/issues/26925
+// https://github.com/rust-lang/rust/issues/52079
+impl<'a, T: 'a> Clone for OCaml<'a, T> {
+ fn clone(&self) -> Self {
+ Self {
+ _marker: PhantomData,
+ raw: self.raw,
+ }
+ }
+}
+
+// As above, avoid unnecessary bounds
+impl<'a, T: 'a> Copy for OCaml<'a, T> {}
+
pub fn make_ocaml<'a, T>(x: RawOCaml) -> OCaml<'a, T> {
OCaml {
_marker: PhantomData,