microsoft / windows-rs

Rust for Windows
https://kennykerr.ca/rust-getting-started/
Apache License 2.0
10.23k stars 476 forks source link

0.58+ implement, how to derive? #3160

Closed LeonarddeR closed 1 month ago

LeonarddeR commented 1 month ago

Summary

I was trying to update to version 0.58, and according to the release notes, it felt as simple as replacing something like impl IClassFactory_Impl for ClassFactory into impl IClassFactory_Impl for ClassFactory_Impl. However, I have #[derive(Debug)] on my struct since I want to use the instrument macro from the tracing crate. Therefore I'd prefer to derive debug on ClassFactory_Impl.

Crate manifest

[dependencies]
tracing = "0.1.40"
tracing-appender = "0.2.3"
tracing-subscriber = "0.3.18"
windows-core = "0.58.0"

[dependencies.windows]
version = "0.58.0"
features = [
    "implement",
    "Win32_Foundation",
    "Win32_System_SystemServices",
    "Win32_System_LibraryLoader",
    "Win32_System_Com",
    "Win32_System_Com_StructuredStorage",
    "Win32_System_Ole",
    "Win32_System_Registry",
    "Win32_System_RemoteDesktop",
]

Crate code

No response

kennykerr commented 1 month ago

cc @sivadeilra

sivadeilra commented 1 month ago

I think we could handle this by forwarding the Debug impl from the outer object to the inner. I'll look into it.

Depending on your use case, you may be able to just dereference the object to get to the inner object. e.g.:

debug!("my object = {:?}", *self);