denoland/rusty_v8

ExternalReference union could use `Debug` implementation

bartlomieju opened this issue · 2 comments

Right now it's not possible to print to the terminal ExternalReference, but it would be
very useful. I'm debugging failures in denoland/deno#19307 and
have no way to inspect pointer addresses being passed to V8.

Since it's a union it's not as easy as adding #[derive(Debug)], we need to provide a manual
implementation. @mmastrac any pointers here would be very appreciated.

graham commented

It looks like there is no clean way to create a descriptive debug implementation due to how unions work in Rust.

I created this diff: graham@35b4fa8

Unfortunately, it doesn't tell you anything about the current variant the union is in, but it might mean that you can #[derive(Debug)] in other structs that contain ExternalReferences.

If this seems like something that would be accepted I can create a pull request, but I'm not sure if this is helpful.

I should have marked this as closed as part of #1272 but any improvements are certainly welcome.