A simple fix might be to ensure that to_string
accept all object with at least the right traits:
module Display = struct
type cap = [`Std_fmt_display | `Core_marker_send ]
type 'a t = ([> cap ] as 'a) Ocaml_rs_smartptr.Rusty_obj.t
external to_string : _ t -> string = "rstdlib_display_to_string"
end
module Error = struct
include Display
type cap =
[ `Ocaml_stdlib_error_wrapper_error_wrapper
| `Std_error_error
| `Core_fmt_debug
| Display.cap
]
type 'a t = ([> cap] as 'a) Ocaml_rs_smartptr.Rusty_obj.t
external source : 'a t -> 'a t option = "rstdlib_error_source"
end