-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Debug Implementations to Remaining Public Types #218
Conversation
There were some types that could not derive Debug automatically in gfx-rs#216 because they (or types they transitively contained) contained types from external crates that do not implement Debug. By adding custom Debug impls, we can handle this case. The Debug impls given here do the same thing #[derive(Debug)] would do, except that they skip the fields that do not themselves implement Debug. After this, all public types will implement Debug, as requested in gfx-rs#76.
@@ -518,6 +527,23 @@ impl Device<back::Backend> { | |||
} | |||
} | |||
|
|||
impl<B: hal::Backend> fmt::Debug for Device<B> { | |||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the queue group the only thing that isn't Debug
? We might want an easier way to solve this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
impl fmt::Debug for Hub { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
f.debug_struct("Hub") | ||
.field("surfaces", &self.surfaces) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is instances the only thing that isn't Debug
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's also adapters
.
.field("device_id", &self.device_id) | ||
.field("desc", &self.desc) | ||
.field("acquired", &self.acquired) | ||
.field("sem_available", &self.sem_available) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is command pool the only thing that isn't Debug
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's also frames
.
In each struct, there are only one or two fields that are incompatible with
Do you have any other ideas? |
I strongly prefer (1)
… On Jun 10, 2019, at 05:11, John W. Bruce ***@***.***> wrote:
In each struct, there are only one or two fields that are incompatible with Debug. Unfortunately, it's not possible to #[derive(Debug) except for this one field] in the standard library. The two alternatives that I've thought of:
Submit changes to the upstream crates to implement Debug for these types, then wait for releases so we can update wgpu's types. They're public types of those crates, so they should really implement Debug anyway.
Derivative contains macros that allow code to omit fields from #[derive(Debug)], but I don't know if you want to take on a dependency.
Do you have any other ideas?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
OK. I'll start tracking all these types down throughout the gfx crate family and get back to you. |
There were some types that could not derive
Debug
automatically in #216 because they (or types they transitively contained) contained types from external crates that do not implementDebug
. By adding customDebug
impls, we can handle this case. The Debug impls given here do the same thing#[derive(Debug)]
would do, except that they skip the fields that do not themselves implementDebug
.After this, all public types will implement
Debug
, as requested in #76.Closes #76